public ActionResult Index([Bind(Include = "ID,AdminEmail,TicketSeeder,FAQApprover,KBApprover,TicketHeader,Keyowrds,ExpertArea,TicketExpiry")] GlobalSettings globalSettings) { if (ModelState.IsValid) { //GlobalSettings globalSettings = gsm.getSettings(); if (globalSettings.ID == Guid.Empty || globalSettings.ID == null) { globalSettings.ID = Guid.NewGuid(); db.GlobalSettingss.Add(globalSettings); } else { db.Entry(globalSettings).State = EntityState.Modified; } db.SaveChanges(); ViewBag.Msg = "Changes saved"; return(RedirectToAction("Index")); } else { ViewBag.Msg = "Model not valid"; } GlobalSettingsEditModel gsm = new GlobalSettingsEditModel(globalSettings); return(View(gsm)); }
public async Task <IActionResult> PutUserTickets(int id, UserTickets userTickets) { if (id != userTickets.UserId) { return(BadRequest()); } _context.Entry(userTickets).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserTicketsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "ID,text,type")] WordListViewModel wordListViewModel) { if (ModelState.IsValid) { db.Entry(wordListViewModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(wordListViewModel)); }
public ActionResult Edit([Bind(Include = "ID,originatorUsername,dateComposed,headerText,description,dateSubmitted,adminEmail,dateL1Release,dateL2Release,sanityCheck")] Ticket ticket) { if (ModelState.IsValid) { db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ticket)); }
public ActionResult Index([Bind(Include = "userID,loginName,principalName,firstName,surName,emailAddress,contactNumber")] UserProfile userProfile) { if (ModelState.IsValid) { db.Entry(userProfile).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("List")); } return(View(userProfile)); }
// POST: Artigo/Votar/5 public ActionResult Votar(String voto, int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Artigo artigo = db.Artigos.Find(id); if (artigo == null) { return(HttpNotFound()); } if (ModelState.IsValid) { if (voto == "true") { artigo.QtdLike++; } if (voto == "false") { artigo.QtdUnlike++; } db.Entry(artigo).State = EntityState.Modified; db.SaveChanges(); return(View("Detalhes", artigo)); } return(View("Detalhes", artigo)); }
public ActionResult Edit([Bind(Include = "Id,Name,Date,Camera,Price,Image,ProducerId,BatteryId,ColorId")] Mobile mobile) { if (ModelState.IsValid) { db.Entry(mobile).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BatteryId = new SelectList(db.Batterys, "Id", "Id", mobile.BatteryId); ViewBag.ColorId = new SelectList(db.Colors, "Id", "Name", mobile.ColorId); ViewBag.ProducerId = new SelectList(db.Producers, "Id", "Name", mobile.ProducerId); return(View(mobile)); }
public ActionResult Edit(User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } SelectList roles = new SelectList(db.Roles, "id", "Name"); ViewBag.Roles = roles; return(View(user)); }
public ActionResult Editar([Bind(Include = "Titulo,TopicoID,SubtopicoID")] Chamado chamadoForm, String conteudoForm, int id) { if (ModelState.IsValid) { List <Chamado> acharChamadoOld = db.Chamados.Where(c => c.Id == id).Include(c => c.Conteudos).ToList(); if (acharChamadoOld != null || acharChamadoOld.Count < 2) { Chamado chamadoEditar = acharChamadoOld.First(); chamadoEditar.DataCriacao = DateTime.Now; // SE mudar o Subtopico if (!chamadoEditar.SubtopicoID.Equals(chamadoForm.SubtopicoID)) { chamadoEditar.SubtopicoID = chamadoForm.SubtopicoID; var listaSubtSuporte = db.Subtopicos.Where(st => st.TopicoID == 1).ToList(); var listaSubtDev = db.Subtopicos.Where(st => st.TopicoID == 2).ToList(); if (listaSubtSuporte.Any(st => st.Id == chamadoForm.SubtopicoID)) { chamadoEditar.EquipeAtendimento = EnumTipoEquipe.Suporte; } else if (listaSubtDev.Any(st => st.Id == chamadoForm.SubtopicoID)) { chamadoEditar.EquipeAtendimento = EnumTipoEquipe.Desenvolvimento; } else { chamadoEditar.EquipeAtendimento = EnumTipoEquipe.Suporte; } } // SE mudar o Titulo if (!chamadoEditar.Titulo.Equals(chamadoForm.Titulo)) { chamadoEditar.Titulo = chamadoForm.Titulo; } // Edita o 'Conteudo' deste chamadoEditar Conteudo conteudoEditar = chamadoEditar.Conteudos.First(); conteudoEditar.ConteudoChamado = conteudoForm; conteudoEditar.DataCriacao = DateTime.Now; db.Entry(conteudoEditar).State = EntityState.Modified; db.Entry(chamadoEditar).State = EntityState.Modified; } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TopicoID = new SelectList(db.Topicos, "Id", "Titulo"); ViewBag.SubtopicoID = new SelectList(db.Subtopicos, "Id", "Titulo"); return(View(chamadoForm)); }
public async Task <IActionResult> PutTicket([FromRoute] int ticketId, TicketForm ticketForm) { // Only owner or team member can update tickets var currentUserId = int.Parse(User.Identity.Name); if (ticketForm.OwnerId != currentUserId && !User.IsInRole("team")) { return(Forbid()); } // Receive ticket id from url var ticket = await _context.Ticket.FindAsync(ticketId); if (ticket == null) { return(NotFound("Ticket not found")); } // Modify ticket ticket.Title = ticketForm.Title; ticket.Content = ticketForm.Content; _context.Entry(ticket).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TicketExists(ticketId)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public virtual void Update(TDomain entity) { _context.Entry(entity).State = EntityState.Modified; _context.Set <TDomain>().Update(entity); }
public void Update(TEndity obj) { Db.Entry(obj).State = EntityState.Modified; Db.SaveChanges(); }