public IActionResult CreateTrack(TrackEditViewModel model) { if (ModelState.IsValid) { EquipmentTracking dp = new EquipmentTracking() { Equipment = EquipmentRepository.Get(model.EquipmentId), Team = TeamRepository.Get(model.TeamId), ServiceRequest = ServiceRequestImp.Get(model.ServiceRequestId), EquipmentDate = DateTime.Parse(model.EquipmentDate), Status = "In use" }; EquipmentTrackingImp.Add(dp); EquipmentTrackingImp.Commit(); HttpContext.Session.SetString("EquipmentTrackSuccess", "The Equipment has been added successfully"); return(RedirectToAction("CreateTrack")); } TrackEditViewModel cu = new TrackEditViewModel() { job = new SelectList(ServiceRequestImp.GetRequest(), "Id", "RequestName"), Team = new SelectList(TeamRepository.GetAll(), "Id", "name"), Equip = new SelectList(EquipmentRepository.GetAll(), "Id", "EquipmentName") }; return(View(cu)); }
public IActionResult EditEquipment(int?id) { if (id == null) { return(RedirectToAction("400")); } var p = EquipmentRepository.Get(id); EquipmentEditModel pk = new EquipmentEditModel() { EquipmentName = p.EquipmentName, EquipmentType = p.EquipmentType, Date = p.EquipmentDate.ToShortDateString(), Time = p.EquipmentDate.ToShortTimeString() }; return(View(pk)); }