public async Task <ServiceResponse <bool> > AddVehicle(MtuReportModelDTO mtuReport) { mtuReport.Email = CurrentUser.UserName; //mtuReport.FullName = return(await HandleApiOperationAsync(async() => { await _mtuReportService.AddReport(mtuReport); return new ServiceResponse <bool>(true); })); }
public async Task AddReport(MtuReportModelDTO report) { //var email = await _userSvc.FindByNameAsync(_serviceHelper.GetCurrentUserEmail()); var employee = await _employeeSvc.GetEmployeesByemailAsync(report.Email); report.FullName = employee.FullName; var mtuReport = new MtuReportModel { Id = report.Id, Notes = report.Notes, FullName = report.FullName, Email = report.Email, VehicleId = report.VehicleId, RegistrationNumber = report.RegistrationNumber, DriverId = report.DriverCode, Status = report.Status, Picture = report.Picture }; _mtuRepo.Insert(mtuReport); await _unitOfWork.SaveChangesAsync(); var getMtu = from repor in _mtuRepo.GetAll() where repor.CreationTime == mtuReport.CreationTime select new MtuReportModel { Id = repor.Id }; foreach (var pics in report.MtuPhotos) { var mtuPhoto = new MtuPhoto { FileName = pics.FileName, MtuReportModelId = getMtu.Select(c => c.Id).FirstOrDefault() }; _mtuPhotoRepo.Insert(mtuPhoto); } await _unitOfWork.SaveChangesAsync(); string smsMessageb = $"An MTU Report was created for Vehicle No: { report.RegistrationNumber}, with Driver: { report.DriverCode} and the status of the Vehicle is: {report.Status.ToString()}. It was reported by {report.FullName}."; await SendSMS(appConfig.MtuSms, smsMessageb); }
public Task UpdateReport(int id, MtuReportModelDTO vehicle) { throw new NotImplementedException(); }