public LocalizationResponse Localize(LocalizationRequest request) { try { var deviceService = new DeviceService(Context); var device = new Device { Name = request.Name, IpAddress = request.IpAddress, MacAddress = request.MacAddress, IsLocalized = request.IsLocalized, Room = new Room { Department = new Department { Name = request.Department }, Name = request.Room }, Location = new Location { Name = request.Location } }; var message = deviceService.Localize(device); return new LocalizationResponse(message); } catch (Exception ex) { return new LocalizationResponse(ex); } }
public ActionResult Unlocalize(Guid id) { var device = Context.Devices.FirstOrDefault(x => x.Id == id); if (device == null) { return HttpNotFound(); } var deviceService = new DeviceService(Context); deviceService.Unlocalize(device); return RedirectToAction("List"); }