[ValidateAntiForgeryToken] //Edit Khalia Info public ActionResult EditKhalia(int Id, [Bind("Id,Ssn,KhaliaLevel,KhaliaType,Wood,PraweezCount,Notes,ManhalId")] Khalias khalias) { if (Id != khalias.Id) { return(NotFound()); } if (ModelState.IsValid) { try { context1.UpdateKhalia(khalias); } catch (DbUpdateConcurrencyException) { ViewData["Average"] = context1.GetKhlaiaStatistics(Id); ViewBagData(); return(View(khalias)); } return(RedirectToAction(nameof(Details), new { id = khalias.ManhalId })); } ViewData["Average"] = context1.GetKhlaiaStatistics(Id); ViewBagData(); return(View(khalias)); }
public Khalias UpdateKhalia(Khalias item) { context.khaliases.Update(item); int x = context.SaveChanges(); return(item); }
public ActionResult AddKhalia(AddKhaliaVM khaliaVM) { if (ModelState.IsValid) { if (context1.Check_SSN_Khalia(khaliaVM.Ssn, khaliaVM.ManhalId) == false) { Khalias khalias = new Khalias(); khalias.Ssn = khaliaVM.Ssn; khalias.KhaliaLevel = khaliaVM.KhaliaLevel; khalias.KhaliaType = khaliaVM.KhaliaType; khalias.ManhalId = khaliaVM.ManhalId; khalias.Notes = khaliaVM.Notes; khalias.PraweezCount = khaliaVM.PraweezCount; khalias.Wood = khaliaVM.Wood; var k = context1.AddKhalia(khalias); Queue queue = new Queue(); queue.DateFertilization = khaliaVM.DateFertilization; queue.KhaliaId = k.Id; queue.QueueStatus = khaliaVM.QueueStatus; context1.AddQueue(queue); return(RedirectToAction(nameof(Details), new { id = khalias.ManhalId })); } } ViewBagData(); return(View(khaliaVM)); }
public ActionResult AddKhalia(int idM) { ViewData["ManhalId"] = idM; ViewBagData(); Khalias k = new Khalias(); k.Queues = new Queue(); return(View(new AddKhaliaVM())); }
public ActionResult DeleteKhalia(int id) { Khalias khalias = context1.getOneKhalia(id); if (khalias != null) { bool b = context1.DeleteKhalia(id); if (b) { return(RedirectToAction(nameof(Details), new { id = khalias.ManhalId })); } } return(RedirectToAction(nameof(EditKhalia), new { id = khalias.ManhalId })); }
public bool DeleteKhalia(int id_Khalia) { Khalias khalias = getOneKhalia(id_Khalia); if (khalias != null) { Queue queue = context.Queues.Where(a => a.KhaliaId == id_Khalia).FirstOrDefault(); if (queue != null) { context.Queues.Remove(queue); context.SaveChanges(); } context.khaliases.Remove(khalias); context.SaveChanges(); return(true); } return(false); }
public bool Check_SSN_Khalia(int SSN, int id_manahal) { if (SSN > 500 || SSN < 1) { return(true); } Khalias khalias = context.khaliases.Where(a => a.ManhalId == id_manahal) .Where(b => b.Ssn == SSN).FirstOrDefault(); if (khalias == null) { return(false); } else { return(true); } }
public Khalias AddKhalia(Khalias item) { context.khaliases.Add(item); context.SaveChanges(); return(context.khaliases.ToList().Last()); }