pavan kumar
pavan kumar

Reputation: 335

Table being updated more than once with the same record

I am working on Visual studio 2013 web,on azure platform using mvc5. I am trying to insert a new record into the table but it is being updated more than once for the same record.In the code below I have view for each action and the flow goes this way:-

I call a action which returns a create view,where i enter the details and must be returned with updated table details.But the table is being updated more than once(in a repetitive sequence of once,twice,thrice).So I tried using a new flow:- I called a action returning the list to a view where i create new record and again call teh updated view which is working.

But now I have to do the same functionality with other tables ,which is getting updated more than once in both approaches.

CustomerDetailsEntities3 cde=new CustomerDetailsEntities3(); 

[Authorize(Roles = "AsstManager")]
public ActionResult AsstManagerHome()
{
    return View();
}

[HttpGet]
[Authorize(Roles = "AsstManager")]
public ActionResult AsstManagerAddCust()
{
    return View();
}

[Authorize(Roles = "AsstManager")]
[HttpPost]
public ActionResult AsstManagerAddCust(CustomerDetail cd)
{
    int x = cde.CustomerDetails.Count();
    cd.Id = x +1;
    cde.CustomerDetails.Add(cd);
    cde.SaveChanges();
    return RedirectToAction("AsstManagerCustDisp");
}

[Authorize(Roles = "AsstManager")]
public ActionResult AsstManagerCustDisp()
{
    return View(cde.CustomerDetails.ToList());
}

I call initially from AsstManagerHome->AsstmanagerAddCust->AsstManagerCustDisp.

Upvotes: 1

Views: 85

Answers (1)

Vamsi
Vamsi

Reputation: 28

If the visual studio is installed more than once the IIS will be installed and this multiple installations may cause the problem.Uninstall the present Visual studio and you will get only one entry. There is no problem with the code.

Upvotes: 1

Related Questions