public ResultViewModel <Track> Update(TrackEditViewModel track) { ResultViewModel <Track> result = new ResultViewModel <Track>(); try { if (!ModelState.IsValid) { result.Message = "In Valid Model State"; } else { Track selectedEmp = trackService.Update(track); result.Successed = true; result.Data = selectedEmp; } } catch (Exception ex) { result.Successed = false; result.Message = "Semething Went Wrong"; } return(result); }
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 ResultViewModel <Track> Post(TrackEditViewModel Track) { ResultViewModel <Track> result = new ResultViewModel <Track>(); try { if (!ModelState.IsValid) { result.Message = "In Valid Model State"; } else { Track selectedTrack = trackService.Add(Track); result.Successed = true; Hub.Clients.All.TrackCount(trackService.Count()); Hub.Clients.All.TrackAdd(Track.Name); result.Data = selectedTrack; } } catch (Exception ex) { result.Successed = false; result.Message = "Semething Went Wrong"; } return(result); }
public IActionResult CreateTrack() { ViewBag.EquipmentTrackSuccess = HttpContext.Session.GetString("EquipmentTrackSuccess"); 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 ActionResult Edit(int id) { var track = _musicRepository.GetTrack(id); if (track == null) { return(HttpNotFound()); } var vm = new TrackEditViewModel(_musicRepository, track); return(View("Edit", vm)); }
public ActionResult Tracks_Update([DataSourceRequest]DataSourceRequest request, TrackEditViewModel model) { if (this.ModelState.IsValid) { var trackEntity = this.tracks.GetById(model.Id); this.Mapper.Map(model, trackEntity); this.tracks.Save(); var responseModel = this.Mapper.Map<TrackListItemViewModel>(trackEntity); return this.Json(new[] { responseModel }.ToDataSourceResult(request, this.ModelState)); } return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult Update(Track track) { if (ModelState.IsValid) { _musicRepository.SaveTrack(track); return(RedirectToAction("Edit", "Album", new { id = track.AlbumID })); } else { var vm = new TrackEditViewModel(_musicRepository, track); return(View("Edit", vm)); } }
public TrackBaseViewModel TrackEdit(TrackEditViewModel editTrack) { var track = ds.Tracks.Find(editTrack.Id); byte[] clipBytes = new byte[editTrack.ClipUpload.ContentLength]; editTrack.ClipUpload.InputStream.Read(clipBytes, 0, editTrack.ClipUpload.ContentLength); track.Clip = clipBytes; track.ClipContentType = editTrack.ClipUpload.ContentType; ds.SaveChanges(); return(track != null?mapper.Map <Track, TrackBaseViewModel>(track) : null); }
public IActionResult EditTrackEquipment(TrackEditViewModel model, int id) { if (ModelState.IsValid) { EquipmentTracking dp = new EquipmentTracking() { Id = id, Equipment = EquipmentRepository.Get(model.EquipmentId), Team = TeamRepository.Get(model.TeamId), ServiceRequest = ServiceRequestImp.Get(model.ServiceRequestId), EquipmentDate = DateTime.Parse(model.EquipmentDate), Status = "Returned" }; EquipmentTrackingImp.Update(dp); EquipmentTrackingImp.Commit(); return(RedirectToAction("ViewTrackEquipment")); } return(View()); }
//11 - TrackEdit - Not working properly public TrackWithDetailViewModel TrackEdit(TrackEditViewModel track) { // Attempt to fetch the object. var obj = ds.Tracks.Find(track.Id); if (obj == null) { // Track was not found, return null. return(null); } else { obj.AudioContentType = track.TrackUpload.ContentType; byte[] trackBytes = new byte[track.TrackUpload.ContentLength]; track.TrackUpload.InputStream.Read(trackBytes, 0, track.TrackUpload.ContentLength); obj.Audio = trackBytes; ds.SaveChanges(); return((obj == null) ? null : mapper.Map <Track, TrackWithDetailViewModel>(obj)); } }
public ActionResult Edit(TrackEditViewModel myTrack) { // Validate the input if (!ModelState.IsValid) { var form = new TrackEditFormViewModel(); form.Name = myTrack.Name; return(View(form)); } // Process the input var editItem = m.TrackEdit(myTrack); if (editItem == null) { return(HttpNotFound()); } else { return(RedirectToAction("Details", "Track", new { id = editItem.Id })); } }
public ActionResult Edit(int?id, TrackEditViewModel track) { if (!ModelState.IsValid) { return(RedirectToAction("Edit", new { id = track.Id })); } if (id.GetValueOrDefault() != track.Id) { return(RedirectToAction("Index")); } var editedEmployee = m.TrackEdit(track); if (editedEmployee != null) { return(RedirectToAction("Index", new { id = track.Id })); } else { return(RedirectToAction("Edit", new { id = track.Id })); } }
public IActionResult EditTrackEquipment(int?id) { if (id == null) { return(RedirectToAction("400")); } var p = EquipmentTrackingImp.Get(id); TrackEditViewModel cu = new TrackEditViewModel() { EquipmentId = p.Equipment.Id, TeamId = p.Team.Id, ServiceRequestId = p.ServiceRequest.Id, Date = p.EquipmentDate.ToShortDateString(), Time = p.EquipmentDate.ToShortTimeString(), Status = p.Status, 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 ActionResult Tracks_Destroy([DataSourceRequest]DataSourceRequest request, TrackEditViewModel model) { this.tracks.Delete(model.Id); return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult Tracks_Destroy([DataSourceRequest] DataSourceRequest request, TrackEditViewModel model) { this.tracks.Delete(model.Id); return(this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState))); }
public ActionResult Tracks_Update([DataSourceRequest] DataSourceRequest request, TrackEditViewModel model) { if (this.ModelState.IsValid) { var trackEntity = this.tracks.GetById(model.Id); this.Mapper.Map(model, trackEntity); this.tracks.Save(); var responseModel = this.Mapper.Map <TrackListItemViewModel>(trackEntity); return(this.Json(new[] { responseModel }.ToDataSourceResult(request, this.ModelState))); } return(this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState))); }