public ActionResult Edit(ComputerEditViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Index", "Error")); } var entity = new Computer { ComputerId = model.Id, RoomNumber = Convert.ToInt32(model.RoomNumber), Name = model.Name, IpAddress = IpAddressHelper.ConvertStringToIpAddress(model.IpAddress), NetworkAddress = IpAddressHelper.ConvertStringToIpAddress(model.NetworkAddress), SubnetAddress = IpAddressHelper.ConvertStringToIpAddress(model.NetworkMask) }; if (entity.ComputerId != 0) { _computerService.UpdateComputer(entity); _historyService.Insert(new History { Email = AuthHelper.GetUser(HttpContext).Email, Action = Action.Update, DateTime = DateTime.Now, Entity = EntityEnum.Computer }); } else { _computerService.CreateComputer(entity); _historyService.Insert(new History { Email = AuthHelper.GetUser(HttpContext).Email, Action = Action.Create, DateTime = DateTime.Now, Entity = EntityEnum.Computer }); } return(RedirectToAction("Index")); }
public async Task <IActionResult> UpdateComputer(ComputerInformation computerInformation) { await _service.UpdateComputer(computerInformation); return(Ok()); }