public static void Insert(Entity.PlanRegulation data) { using (var context = new Entity.OiWeb()) { context.PlanRegulations.Add(data); context.SaveChanges(); } }
public RedirectResult Update(Entity.PlanRegulation entity) { if (!entity.idPlanRegulation.Equals(0)) { Business.PlanRegulation.Update(entity); } return(Redirect("~/Grupos/" + entity.idPlanRegulation + "/regulamentos")); }
public RedirectResult Save(Entity.PlanRegulation entity) { if (entity.file != null) { var fileLocation = Server.MapPath("~/Content/Upload/Regulation/" + entity.file.FileName); entity.file.SaveAs(fileLocation); entity.link = "/Content/Upload/Regulation/" + entity.file.FileName; } Business.PlanRegulation.Insert(entity); return(Redirect("/regulamentos")); }
public static void Update(Entity.PlanRegulation data) { using (var context = new Entity.OiWeb()) { var planregulation = context.PlanRegulations.Find(data.idPlanRegulation); if (planregulation != null) { context.PlanRegulations.Attach(planregulation); var entry = context.Entry(planregulation); entry.Property(e => e.name).IsModified = true; entry.Property(e => e.link).IsModified = true; entry.Property(e => e.type).IsModified = true; context.SaveChanges(); } } }