public ActionResult SocialEdit(SocialEdit model) { Social Updated_Social = db.Socials.Where(a => a.id == model.Id).FirstOrDefault(); Updated_Social.SocialUrl = model.SocialUrl; Updated_Social.SocialName = model.SocialName; db.SubmitChanges(); return(RedirectToAction("Social")); }
public ActionResult Edit(int id) { var service = CreateSocialService(); var detail = service.GetSocialById(id); var model = new SocialEdit { SocialId = detail.SocialId, CategoryType = detail.CategoryType, Title = detail.Title, ResourceType = detail.ResourceType, Description = detail.Description, City = detail.City, State = detail.State, InPerson = detail.InPerson, Url = detail.Url, }; return(View(model)); }
public bool UpdateSocial(SocialEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Socials .Single(e => e.SocialId == model.SocialId && e.OwnerId == _userId); entity.CategoryType = model.CategoryType; entity.Title = model.Title; entity.ResourceType = model.ResourceType; entity.Description = model.Description; entity.City = model.City; entity.State = model.State; entity.InPerson = model.InPerson; entity.Url = model.Url; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, SocialEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.SocialId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateSocialService(); if (service.UpdateSocial(model)) { TempData["SaveResult"] = "Successfully updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your entry could not be updated."); return(View(model)); }