public ActionResult changeSlot(int id, int wid) { Availability_Slots slot = ctx.Availability_Slots.FirstOrDefault(obj => obj.Id == id); if (slot.IsAvailable == 1) { slot.IsAvailable = 0; } else if (slot.IsAvailable == 0) { slot.IsAvailable = 1; } ctx.SaveChanges(); return(RedirectToAction("EditWorker/" + wid)); }
public void saveworker(worker_Portfolio a) { ctx.worker_Portfolio.Add(a); try { ctx.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } Availability_Slots slot = new Availability_Slots(); slot.Availability_Slots1 = "10am - 11am"; slot.wid = a.Id; slot.IsAvailable = 0; ctx.Availability_Slots.Add(slot); Availability_Slots slot1 = new Availability_Slots(); slot1.Availability_Slots1 = "11am - 12pm"; slot1.wid = a.Id; slot1.IsAvailable = 0; ctx.Availability_Slots.Add(slot1); Availability_Slots slot2 = new Availability_Slots(); slot2.Availability_Slots1 = "12pm-1pm"; slot2.wid = a.Id; slot2.IsAvailable = 0; ctx.Availability_Slots.Add(slot2); Availability_Slots slot3 = new Availability_Slots(); slot3.Availability_Slots1 = "1pm-2pm"; slot3.wid = a.Id; slot3.IsAvailable = 0; ctx.Availability_Slots.Add(slot3); Availability_Slots slot4 = new Availability_Slots(); slot4.Availability_Slots1 = "2pm-3pm"; slot4.wid = a.Id; slot4.IsAvailable = 0; ctx.Availability_Slots.Add(slot4); Availability_Slots slot5 = new Availability_Slots(); slot5.Availability_Slots1 = "3pm-4pm"; slot5.wid = a.Id; slot5.IsAvailable = 0; ctx.Availability_Slots.Add(slot5); Availability_Slots slot6 = new Availability_Slots(); slot6.Availability_Slots1 = "4pm-5pm"; slot6.wid = a.Id; slot6.IsAvailable = 0; ctx.Availability_Slots.Add(slot6); Availability_Slots slot7 = new Availability_Slots(); slot7.Availability_Slots1 = "5pm-6pm"; slot7.wid = a.Id; slot7.IsAvailable = 0; ctx.Availability_Slots.Add(slot7); Availability_Slots slot8 = new Availability_Slots(); slot8.Availability_Slots1 = "6pm-7pm"; slot8.wid = a.Id; slot8.IsAvailable = 0; ctx.Availability_Slots.Add(slot8); Availability_Slots slot9 = new Availability_Slots(); slot9.Availability_Slots1 = "7pm-8pm"; slot9.wid = a.Id; slot9.IsAvailable = 0; ctx.Availability_Slots.Add(slot9); try { ctx.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } for (int i = 0; i < Request.Files.Count; i++) { try { HttpPostedFileBase file = Request.Files[i]; file.SaveAs(Server.MapPath(@"~\worker_" + a.Id + ".jpeg")); } catch (Exception ex) { } break; } Response.Redirect("/Admin/Main"); }