Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • TheArtist 22 posts 71 karma points
    Jan 14, 2016 @ 13:48
    TheArtist
    0

    Delete record petapoco

    Hello,

    I am having some issues in database Umbraco MVC. The problem is that my records is deleted ok but sometimes they come back!

        [HttpGet]
        public ActionResult Delete(string kursusDeltagerId)
        {
            var db = ApplicationContext.DatabaseContext.Database;
            db.Execute("DELETE FROM tblTilmeldtQueue WHERE cDeltagerId=@0", kursusDeltagerId);
            return Redirect("/myview-oversigt/?id=4");
        }
    
        [HttpGet]
        public ActionResult DeleteFromOrder(string kursusDeltagerId)
        {
            var db = ApplicationContext.DatabaseContext.Database;
            db.Execute("DELETE FROM tblTilmeldt WHERE cDeltagerId=@0", kursusDeltagerId);
            return Redirect("/myview-oversigt/?id=4");
        }
    

    I call delete from my view with the following code.

    @Html.ActionLink("Fortryd", "Delete", "kursusOversigtSurface", new { kursusDeltagerId = @item.kursusDeltagerId }, null

    My tables is created in the umbraco database.

    Thanks in advance,

    Best regards

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Jan 14, 2016 @ 15:19
    Alex Skrypnyk
    1

    Hi Jakob,

    Interesting situation, can you reproduce the bug ?

    What version of Umbraco are you using ?

    Maybe you can find something in UmbracoTraceLog ?

    I delete rows like that

            var query = new Sql().Select("*").From("Reviews").Where<ReviewDto>(x => x.Id == id);
    
            var reviewFromDb = ApplicationContext.Current.DatabaseContext.Database.Fetch<ReviewDto>(query).FirstOrDefault();
    
            var deletedReviewId = ApplicationContext.Current.DatabaseContext.Database.Delete(reviewFromDb);
    

    Thanks,

    Alex

  • TheArtist 22 posts 71 karma points
    Jan 27, 2016 @ 10:10
    TheArtist
    1

    Hi Alex,

    Thanks for your reply.

    I have been debugging and found out that the problem is not related to the database part.

    The problem is that all actions sometimes is called twize. I have been looking at W3 traffic on the IIS server and here there was only one call to my actions.

    My setup is that I have a RenderMvcController on the actual page with a SurfaceController and a RenderModel.

    I have found a solution but am still interested in this issues.

    Best regards, Jakob

Please Sign in or register to post replies

Write your reply to:

Draft