private void AddMaintenance() { var form = this.CurrentMdiChild(); // Check if there is a current MDI child before invoking the new process. if (null == form || form.GetType() != typeof(VehicleList)) { ViewHelper.ShowErrorMessage("You must select a Vehicle record before adding new maintenance."); return; } var vehicleList = (IListForm)form; var vehicleInfo = vehicleList.GetSelectedItem(); if (null != vehicleInfo) { var dialog = new MaintenanceEdit(); // Invoke ShowObject method by passing the current VehicleInfo object. // Make sure that the dialog respondes as expected (i.e. it should check the type of the parameter). // You might be tempted to instantiate a new instance of Maintenance object but we DO NOT NEED to // refrenece the business layer from the shell. dialog.ShowObject(vehicleInfo); dialog.ShowDialog(); } }
public async Task<ActionResult> Edit(MaintenanceEdit model) { var service = EstablishMaintenanceService(); if (await service.EditMaintenanceAsync(model)) { return RedirectToAction("Index"); } ModelState.AddModelError("", "Request does not meet the maintenance model specifications"); return View(model); }
//Maintenance Edit: GetByID and PUT public async Task<ActionResult> Edit(int id) { var service = EstablishMaintenanceService(); var detail = await service.GetMaintenanceByIdAsync(id); var model = new MaintenanceEdit { MaintenanceID = detail.MaintenanceID, Category = detail.Category, Description = detail.Description, Active = detail.Active, Permission = detail.Permission, }; return View(model); }
public async Task <bool> EditMaintenanceAsync(MaintenanceEdit model) { var entity = await _context .Maint .SingleOrDefaultAsync(e => e.MaintenanceID == model.MaintenanceID); entity.Category = model.Category; entity.Description = model.Description; entity.Active = model.Active; entity.Permission = model.Permission; entity.PropertyID = model.PropertyID; /*FK*/ return(await _context.SaveChangesAsync() == 1); }
public bool UpdateMaintenance(MaintenanceEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Maintenances .Single(e => e.MaintenanceId == model.MaintenanceId && e.MaintenanceOwnerId == _maintenanceUserId); entity.MaintenanceId = model.MaintenanceId; entity.OdomoterMileage = model.OdomoterMileage; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }