public void AddEquipment(EquipmentModel equipmentModel) { var equipment = factoryContext.Equipment.Where(eq => eq.Title == equipmentModel.Title).ToList(); if (equipment.Count == 0) { factoryContext.Equipment.Add(new Equipment() { Title = equipmentModel.Title }); factoryContext.RoomEquipment.Add(new RoomEquipment() { RoomId = (int)equipmentModel.RoomId, EquipmentId = equipmentModel.Id, EquipmentNumber = equipmentModel.Number }); } else { var equipmentForRoom = factoryContext.RoomEquipment.Find(equipmentModel.RoomId, equipment[0].Id); equipmentForRoom.EquipmentNumber += equipmentModel.Number; factoryContext.Entry(equipmentForRoom).State = EntityState.Modified; } factoryContext.SaveChanges(); }
public void Update(Machine machine) { if (machine != null) { context.Entry(machine).State = EntityState.Modified; } }
public ActionResult Edit(License license, int EngineerId, int MachineTypeId) { if (MachineTypeId != 0) { bool tf = _db.LicenseType.Any(x => x.LicenseId == license.LicenseId && x.MachineTypeId == MachineTypeId); if (!tf) { _db.LicenseType.Add(new LicenseType() { MachineTypeId = MachineTypeId, LicenseId = license.LicenseId }); } } if (EngineerId != 0) { bool tf = _db.EngineerLicense.Any(x => x.LicenseId == license.LicenseId && x.EngineerId == EngineerId); if (!tf) { _db.EngineerLicense.Add(new EngineerLicense() { EngineerId = EngineerId, LicenseId = license.LicenseId }); } } _db.Entry(license).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", null, new { id = license.LicenseId })); }
public void Update(Request request) { if (request != null) { context.Entry(request).State = EntityState.Modified; } }
public ActionResult Edit(Machine machine, string StatusTypes) { machine.Status = StatusTypes; _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public void Update(Deliverer deliverer) { if (deliverer != null) { context.Entry(deliverer).State = EntityState.Modified; } }
// PUT api/Service/5 public HttpResponseMessage PutCity(int id, City city) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != city.Id) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } db.Entry(city).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public void Update(Employee emp) { if (emp != null) { context.Entry(emp).State = EntityState.Modified; } }
public ActionResult Edit(City city) { if (ModelState.IsValid) { db.Entry(city).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(city)); }
public ActionResult Edit([Bind(Include = "FactoryId,FactoryName")] Factory factory) { if (ModelState.IsValid) { db.Entry(factory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(factory)); }
public ActionResult Edit([Bind(Include = "UserId,Username,Password,ConfirmPassword,IsLogged")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Edit(Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CityId = new SelectList(db.Cities, "Id", "Name", product.CityId); return(View(product)); }
public ActionResult Edit(Machine machine, int EngineerId) { var joinConfirm = _db.EngineerMachine.FirstOrDefault(join => join.MachineId == machine.MachineId && join.EngineerId == EngineerId); if (joinConfirm != null) { _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", new { id = machine.MachineId })); } if (EngineerId != 0) { _db.EngineerMachine.Add(new EngineerMachine() { EngineerId = EngineerId, MachineId = machine.MachineId }); } _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", new { id = machine.MachineId })); }
public ActionResult Edit(Machine machine, int LicenseId) { if (LicenseId != 0) { _db.MachineLicense.Add(new MachineLicense() { LicenseId = LicenseId, MachineId = machine.MachineId }); } _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Treat treat, int FlavorId) { if (FlavorId != 0) { _db.FlavorTreat.Add(new FlavorTreat() { FlavorId = FlavorId, TreatId = treat.TreatId }); } _db.Entry(treat).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Engineer engineer, int MachineId, Machine machine) { if (MachineId != 0) { _db.EngineerMachine.Add(new EngineerMachine() { MachineId = MachineId, EngineerId = engineer.EngineerId }); } _db.Entry(engineer).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", new { id = engineer.EngineerId })); }
public ActionResult Edit(Machine machine, int EngineerId) { if (EngineerId != 0) { _db.EngineerMachine.Add(new EngineerMachine() { EngineerId = EngineerId, MachineId = machine.MachineId }); } _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Engineer engineer, int MachineId) { if (MachineId != 0) { _db.MachineEngineer.Add(new MachineEngineer() { MachineId = MachineId, EngineerId = engineer.EngineerId }); } _db.Entry(engineer).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Machine machine, int EngineerId) { if (EngineerId != 0) { _db.EngineerMachine.Add(new EngineerMachine() { EngineerId = EngineerId, MachineId = machine.MachineId }); } _db.Entry(machine).State = EntityState.Modified; // Holds all information for engineer _db.SaveChanges(); // sends information for engineer to database return(RedirectToAction("Index")); // returns to the index page of Machines. }
public ActionResult Edit([Bind(Include = "EmployerId,FirstName,LastName,PhoneNumber,FactoryId")] Employer employer) { if (ModelState.IsValid) { var listOfFactories = db.Factories.ToList(); SelectList list = new SelectList(listOfFactories, "FactoryId", "FactoryName"); ViewBag.FactoryListName = list; db.Entry(employer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employer)); }
public ActionResult Edit(Engineer engineer, int MachineId) { bool duplicate = _db.Repair.Any(x => x.MachineId == MachineId && x.EngineerId == engineer.EngineerId); if (MachineId != 0 && !duplicate) { _db.Repair.Add(new Repair { MachineId = MachineId, EngineerId = engineer.EngineerId }); } _db.Entry(engineer).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Machine machine, int engineerId) { bool duplicate = _db.EngineerMachine.Any(engiMach => engiMach.EngineerId == engineerId && engiMach.MachineId == machine.MachineId); if (engineerId != 0 && !duplicate) { _db.EngineerMachine.Add(new EngineerMachine() { EngineerId = engineerId, MachineId = machine.MachineId }); } _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Machine machine, int EngineerId, int joinId) { if (EngineerId != 0) { var joinEntry = _db.EngineerMachine.FirstOrDefault(entry => entry.EngineerMachineId == joinId); _db.EngineerMachine.Remove(joinEntry); _db.EngineerMachine.Add(new EngineerMachine() { EngineerId = EngineerId, MachineId = machine.MachineId }); } _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Machine machine) { if (machine.Name is null) { ViewBag.EngineerId = new SelectList(_db.Engineers, "EngineerId", "Name"); ViewBag.ErrorMessage = "Please enter a name"; return(View(machine)); } else { _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", new { machineId = machine.MachineId })); } }
public ActionResult Edit(Machine machine, int EngineerId, DateTime InstallationDate) { machine.InstallationDate = InstallationDate; bool duplicate = _db.Repair.Any(x => x.EngineerId == EngineerId && x.MachineId == machine.MachineId); if (EngineerId != 0 && !duplicate) { _db.Repair.Add(new Repair { EngineerId = EngineerId, MachineId = machine.MachineId }); } _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Machine machine, List <int> engineers) { if (engineers.Count != 0) { foreach (int engineer in engineers) { _db.EngineerMachine.Add(new EngineerMachine() { EngineerId = engineer, MachineId = machine.MachineId }); } } _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Engineer engineer, int[] MachineId) { if (MachineId.Length != 0) { foreach (int id in MachineId) { _db.EngineersMachines.Add(new EngineerMachine() { MachineId = id, EngineerId = engineer.EngineerId }); } } _db.Entry(engineer).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Machine machine, int engineerId) { bool duplicate = _db.EngineerMachines.Any(join => join.EngineerId == engineerId && join.MachineId == machine.MachineId); if (engineerId != 0 && !duplicate) { _db.EngineerMachines.Add(new EngineerMachine() { EngineerId = engineerId, MachineId = machine.MachineId }); } _db.Entry(machine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", new { id = machine.MachineId })); }
public ActionResult Edit(MachineType machineType, int LicenseId) { if (LicenseId != 0) { bool tf = _db.LicenseType.Any(x => x.LicenseId == LicenseId && x.MachineTypeId == machineType.MachineTypeId); if (!tf) { _db.LicenseType.Add(new LicenseType() { MachineTypeId = machineType.MachineTypeId, LicenseId = LicenseId }); } } _db.Entry(machineType).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", null, new { id = machineType.MachineTypeId })); }
public ActionResult Edit(Engineer engineer, int LicenseId) { if (LicenseId != 0) { bool tf = _db.EngineerLicense.Any(x => x.LicenseId == LicenseId && x.EngineerId == engineer.EngineerId); if (!tf) { _db.EngineerLicense.Add(new EngineerLicense() { EngineerId = engineer.EngineerId, LicenseId = LicenseId }); } } _db.Entry(engineer).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", null, new { id = engineer.EngineerId })); }