public IResponseDTO EditWorkshop(WorkshopVM model) { try { var DbWorkshop = _mapper.Map <Workshop>(model); var entityEntry = _WorkshopRepositroy.Update(DbWorkshop); int save = _unitOfWork.Commit(); if (save == 200) { _response.Data = model; _response.IsPassed = true; _response.Message = "Ok"; } else { _response.Data = null; _response.IsPassed = false; _response.Message = "Not saved"; } } catch (Exception ex) { _response.Data = null; _response.IsPassed = false; _response.Message = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : ""); } return(_response); }
public async Task <IActionResult> CheckAssignedVendor(WorkshopVM workshopVM) { try { WorkshopVM workshop = await(from a in dbContext.AssignedWorkshops where a.IncidentId == workshopVM.IncidentId select new WorkshopVM() { CheckId = workshopVM.CheckId, Code = a.SupplierCode, IncidentId = workshopVM.IncidentId, IncidentType = workshopVM.IncidentType, Type = a.SupplierType, Remarks = a.Remarks }).FirstOrDefaultAsync(); if (workshop != null) { return(Ok(workshop)); } else { return(NotFound()); } } catch (Exception) { return(BadRequest()); } }
public IResponseDTO WorkshopLogin(WorkshopVM model) { try { var res = _WorkshopRepositroy.GetFirst(X => X.Email == model.Email && X.Password == model.Password); if (res == null) { _response.Data = null; _response.IsPassed = false; _response.Message = "Not saved"; } else { //var DbWorkshop = _mapper.Map<WorkshopVM>(res); //_response.Data = DbWorkshop; //_response.IsPassed = true; //_response.Message = "Ok"; res.Token = model.Token; return(EditWorkshop(_mapper.Map <WorkshopVM>(res))); } } catch (Exception ex) { _response.Data = null; _response.IsPassed = false; _response.Message = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : ""); } return(_response); }
public IResponseDTO NewUpdateWorkshop([FromForm] WorkshopVM Workshop) { ResponseDTO res; try { if (Workshop.ShopFile != null) { var logoUrl = BackEnd.API.Hlper.UploadHelper.SaveFile(Workshop.ShopFile, "File"); Workshop.ImageUrl = logoUrl; Workshop.ShopFile = null; } if (Workshop.OwnerFile != null) { var logoUrl = BackEnd.API.Hlper.UploadHelper.SaveFile(Workshop.OwnerFile, "File"); Workshop.OwnerImage = logoUrl; Workshop.OwnerFile = null; } return(_WorkshopServices.EditWorkshop(Workshop)); } catch (Exception ex) { res = new ResponseDTO() { IsPassed = false, Message = "Error in Upload File " + ex.Message, Data = null, }; } return(res); }
public async Task <IActionResult> AssignVendors(WorkshopVM workshopVM) { try { string code = "", name = ""; if (workshopVM.Type == "Approved") { var vendor = await(from a in viewsContext.PblVendorManagements where a.XCode == workshopVM.Code select a).FirstOrDefaultAsync(); code = vendor.XCode; name = vendor.XName; } else if (workshopVM.Type == "Un Approved") { var driver = await(from d in dbContext.Drivers where d.Code == workshopVM.Code select d).FirstOrDefaultAsync(); code = driver.Code; name = driver.Name; } AssignedWorkshop workshop = new AssignedWorkshop() { Id = Guid.NewGuid(), IncidentId = workshopVM.IncidentId, SupplierType = workshopVM.Type, SupplierCode = code, SupplierName = name, Remarks = workshopVM.Remarks }; await dbContext.AssignedWorkshops.AddAsync(workshop); if (await dbContext.SaveChangesAsync() > 0) { if (workshopVM.IncidentType == "Emergency") { FMSEmergencyCheck check = await(from c in dbContext.FMSEmergencyCheckList where c.Id == workshopVM.CheckId select c).FirstOrDefaultAsync(); check.LastUpdated = PakistanDateTime.Now; check.MaintenanceStatus = Shared.Enums.CheckMaintenanceStatus.InProgress; Emergency emergency = await(from c in dbContext.Emergencies where c.Id == workshopVM.IncidentId select c).FirstOrDefaultAsync(); emergency.LastUpdated = PakistanDateTime.Now; if (await dbContext.SaveChangesAsync() > 0) { return(Ok()); } else { return(BadRequest()); } } else if (workshopVM.IncidentType == "Accident") { FMSAccidentalCheck check = await(from c in dbContext.FMSAccidentalCheckList where c.Id == workshopVM.CheckId select c).FirstOrDefaultAsync(); check.LastUpdated = PakistanDateTime.Now; check.MaintenanceStatus = Shared.Enums.CheckMaintenanceStatus.InProgress; Accident accident = await(from c in dbContext.Accidents where c.Id == workshopVM.IncidentId select c).FirstOrDefaultAsync(); accident.LastUpdated = PakistanDateTime.Now; if (await dbContext.SaveChangesAsync() > 0) { return(Ok()); } else { return(BadRequest()); } } return(NotFound()); } else { return(BadRequest()); } } catch (Exception) { return(BadRequest()); } }
public IResponseDTO postWorkshop(WorkshopVM WorkshopVM) { var depart = _WorkshopServices.PostWorkshop(WorkshopVM); return(depart); }
public IResponseDTO RemoveWorkshop(WorkshopVM WorkshopVM) { var depart = _WorkshopServices.DeleteWorkshop(WorkshopVM); return(depart); }
public IResponseDTO UpdateWorkshop(WorkshopVM WorkshopVM) { var depart = _WorkshopServices.EditWorkshop(WorkshopVM); return(depart); }