public virtual void Delete(TEntity entityToDelete) { if (Context.Entry(entityToDelete).State == EntityState.Detached) { DbSet.Attach(entityToDelete); } DbSet.Remove(entityToDelete); }
public ActionResult Edit([Bind(Include = "deelnemer_id,voornaam,achternaam,email,evenement,goedgekeurd")] Deelnemer deelnemer) { if (ModelState.IsValid) { db.Entry(deelnemer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(deelnemer)); }
public ActionResult Edit([Bind(Include = "Id,Wartosc,Opis,KryteriumID,PortalId,AnalizaId")] Ocena_Kryterium ocena_Kryterium) { if (ModelState.IsValid) { db.Entry(ocena_Kryterium).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.KryteriumID = new SelectList(db.Kryteria, "Id", "Nazwa", ocena_Kryterium.KryteriumID); ViewBag.AnalizaId = new SelectList(db.Analizy, "Id", "Nazwa", ocena_Kryterium.AnalizaId); ViewBag.PortalId = new SelectList(db.Portale, "ID", "Nazwa", ocena_Kryterium.PortalId); return(View(ocena_Kryterium)); }
//Reads the wijziging and executes the stored database change private void ExecuteWijziging(Wijziging wijziging) { object Wijzigingobject = new JavaScriptSerializer().Deserialize(wijziging.jsonData, Type.GetType(wijziging.jsonClassType)); string type = wijziging.jsonClassType.Substring(24); //Insert if (wijziging.WijzigingsType.type_id == 1) { if (type == "Evenement") { db.Evenements.Add(Wijzigingobject as Evenement); } else if (type == "Activiteit") { db.Activiteits.Add(Wijzigingobject as Activiteit); } } //Delete else if (wijziging.WijzigingsType.type_id == 2) { if (type == "Evenement") { db.Evenements.Remove(db.Evenements.Find((Wijzigingobject as Evenement).evenement_id)); } else if (type == "Activiteit") { db.Activiteits.Remove(db.Activiteits.Find((Wijzigingobject as Activiteit).activiteit_id)); } } //Update //TODO object can be removed before Update wijziging is used creating a concurrency exeption else if (wijziging.WijzigingsType.type_id == 3) { if (type == "Evenement") { Evenement newEvent = Wijzigingobject as Evenement; Evenement oldEvent = db.Evenements.Find(newEvent.evenement_id); oldEvent.naam = newEvent.naam; oldEvent.beschrijving = newEvent.beschrijving; oldEvent.begindatum = newEvent.begindatum; oldEvent.einddatum = newEvent.einddatum; db.Entry(oldEvent).State = EntityState.Modified; } else if (type == "Activiteit") { db.Entry(Wijzigingobject as Activiteit).State = EntityState.Modified; } } db.Wijzigings.Remove(wijziging); db.SaveChanges(); }
public ActionResult Edit([Bind(Include = "Id,Name,Branch,EducationalQualifications,Email,DOB")] Faculty faculty) { if (ModelState.IsValid) { db.Entry(faculty).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(faculty)); }
public ActionResult Edit([Bind(Include = "ID,Nazwa,Opis")] Portal portal) { if (ModelState.IsValid) { db.Entry(portal).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(portal)); }
public ActionResult Edit([Bind(Include = "Id,paperDate,Name,Description,isPublic")] Paper paper) { if (ModelState.IsValid) { db.Entry(paper).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(paper)); }
public ActionResult Edit([Bind(Include = "Id,Name,Sem")] Subject subject) { if (ModelState.IsValid) { db.Entry(subject).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subject)); }
public ActionResult Edit([Bind(Include = "id,name")] Kryterium kryterium) { if (ModelState.IsValid) { db.Entry(kryterium).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(kryterium)); }
public ActionResult Edit([Bind(Include = "ID,Nazwa,DataAnalizy")] Analiza analiza) { if (ModelState.IsValid) { db.Entry(analiza).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(analiza)); }
public ActionResult Edit([Bind(Include = "beheerder_id,voornaam,achternaam,gebruikersnaam,wachtwoord")] Beheerder beheerder) { if (ModelState.IsValid) { db.Entry(beheerder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(beheerder)); }
public ActionResult Edit([Bind(Include = "Id,Name,DOB,Sem,Branch,Email,Phone")] Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Edit(ProjectType projecttype) { if (ModelState.IsValid) { db.Entry(projecttype).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(projecttype)); }
public ActionResult Edit([Bind(Include = "QuestionId,Description,Marks,Answer,Hint")] Question question) { if (ModelState.IsValid) { db.Entry(question).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(question)); }
public ActionResult Edit(ProjectActivity projectactivity) { if (ModelState.IsValid) { db.Entry(projectactivity).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OwnerUserID = new SelectList(db.UserProfiles, "UserId", "UserName", projectactivity.OwnerUserID); ViewBag.ProjectTypeID = new SelectList(db.ProjectTypes, "ProjectTypeID", "Description", projectactivity.ProjectTypeID); return(View(projectactivity)); }
public ActionResult Edit([Bind(Include = "Id,Wartosc,AnalizaId,KryteriumId")] Waga waga) { if (ModelState.IsValid) { db.Entry(waga).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AnalizaId = new SelectList(db.Analizy, "Id", "Nazwa", waga.AnalizaId); ViewBag.KryteriumId = new SelectList(db.Kryteria, "Id", "Nazwa", waga.KryteriumId); return(View(waga)); }
public ActionResult Edit(UserProject userproject) { if (ModelState.IsValid) { db.Entry(userproject).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProjectActivityID = new SelectList(db.ProjectActivities, "ProjectActivityID", "Name", userproject.ProjectActivityID); ViewBag.UserID = new SelectList(db.UserProfiles, "UserId", "UserName", userproject.UserID); return(View(userproject)); }
public JsonResult Salvar(List <ListaCompra> dadosWeb) { var itensListaBanco = db.Set <ListaCompra>().ToList(); foreach (var item in dadosWeb) { var itemLista = itensListaBanco.FirstOrDefault(f => f.Id == item.Id); if (itemLista == null) { var novoItemLista = new ListaCompra(); novoItemLista.IdAlimento = item.IdAlimento; novoItemLista.Quantidade = item.Quantidade; db.ListaCompra.Add(novoItemLista); } } foreach (var listItem in itensListaBanco) { var itemLista = dadosWeb.FirstOrDefault(f => f.Id == listItem.Id); if (itemLista != null) { db.Entry <ListaCompra>(listItem).CurrentValues.SetValues(itemLista); } } foreach (var item in itensListaBanco) { var itemLista = dadosWeb.FirstOrDefault(f => f.Id == item.Id); if (itemLista == null) { db.Entry <ListaCompra>(item).State = System.Data.Entity.EntityState.Deleted; } } db.SaveChanges(); return(Json(new { })); }
public virtual ActionResult Page() { var model = GetById <Location>(WebContext.Location.Id); SetLocalizationRedirects(); if (model == null) { return(HttpNotFound()); } DataModelContext.Entry(model).Collection(x => x.Blocks).Load(); //var lang = DependencyResolver.Current.GetService<ILocalizationContext>(); RenderHomePageDb dbf = new RenderHomePageDb(); WebContext.Location = dbf.RenderModelHome(WebContext.Location, WebContext.Location.Id); return(View(WebContext.Location)); }
public ActionResult Edit([Bind(Include = "evenement_id,naam,beschrijving,begindatum,einddatum")] Evenement evenement) { if (ModelState.IsValid) { if (db.Evenements.Find(evenement.evenement_id).EvenementBeheerders.Count() > 1) { TempData["wijziging"] = GenerateWijziging(evenement, 3); return(RedirectToAction("Create", "Wijzigingen", null)); } else { db.Entry(evenement).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Dashboard", new { id = evenement.evenement_id })); } } return(View(evenement)); }
public ActionResult Edit([Bind(Include = "activiteit_id,naam,beschrijving,evenement,begintijd,eindtijd,evenement_beheerder,voltooid")] Activiteit activiteit) { if (ModelState.IsValid) { if (db.Evenements.Find(activiteit.evenement).EvenementBeheerders.Count() > 1) { TempData["wijziging"] = GenerateWijziging(activiteit, 3); return(RedirectToAction("Create", "Wijzigingen", null)); } else { db.Entry(activiteit).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Dashboard", "Evenementen", new { id = activiteit.evenement })); } } return(View(activiteit)); }
public virtual ActionResult Index() { var model = GetEntities <Partner>().Include(x => x.Countries).Include(x => x.Logo).Where(x => x.Visibility).ToList(); if (DataModelContext.Entry(WebContext.Location).State == EntityState.Unchanged) { DataModelContext.Entry(WebContext.Location).Collection(x => x.Images).Load(); } var countries = model.SelectMany(x => x.Countries).Distinct(); countries.ToList().ForEach(x => { x.Name = Localize("country.name." + x.Name); }); foreach (var p in model) { p.Name = Localize(p.Name); p.Url = Localize(p.Url); } return(View(model)); }