public ActionResult Partners_Create([DataSourceRequest]DataSourceRequest request, Partner partner) { if (ModelState.IsValid) { var entity = new Partner { Name = partner.Name, Logo = partner.Logo, Website = partner.Website, Description = partner.Description, JoinedOn = partner.JoinedOn, PartnershipLevel = partner.PartnershipLevel }; db.Partners.Add(entity); db.SaveChanges(); partner.Id = entity.Id; } return Json(new[] { partner }.ToDataSourceResult(request, ModelState)); }
public ActionResult Partners_Update([DataSourceRequest]DataSourceRequest request, Partner partner) { if (ModelState.IsValid) { var entity = new Partner { Id = partner.Id, Name = partner.Name, Logo = partner.Logo, Website = partner.Website, Description = partner.Description, JoinedOn = partner.JoinedOn, PartnershipLevel = partner.PartnershipLevel }; db.Partners.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return Json(new[] { partner }.ToDataSourceResult(request, ModelState)); }