public IActionResult Add(ContractCloseOutViewModel viewModel) { try { Guid resourceId = Post(viewModel); var contractNumber = _contractService.GetContractNumberById(viewModel.ContractGuid); var uploadPath = string.Format($@"{contractNumber}\ContractClose"); var fileParentDetails = _contractService.GetFilesByContractGuid(viewModel.ContractGuid, EnumGlobal.ResourceAction.Closeout.ToString()); bool isTaskOrder = viewModel.ParentContractGuid != Guid.Empty ? true : false; var parentId = fileParentDetails != null ? fileParentDetails.ContractResourceFileGuid : Guid.Empty; var jsonObject = new { status = true, resourceId = resourceId, uploadPath = uploadPath, contractGuid = viewModel.ContractGuid, representativeType = viewModel.RepresentativeType, parentId = parentId, taskOrder = isTaskOrder }; return(Json(jsonObject)); } catch (Exception e) { ModelState.AddModelError("", e.Message); return(BadRequestFormatter.BadRequest(this, e)); } }
public IActionResult Add([FromForm] ContractFileViewModel fileModel) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } fileModel.CreatedOn = CurrentDateTimeHelper.GetCurrentDateTime(); fileModel.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime(); fileModel.CreatedBy = UserHelper.CurrentUserGuid(HttpContext); fileModel.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext); fileModel.IsActive = true; fileModel.IsDeleted = false; fileModel.IsCsv = true; // gets the contractnumber to save the file in the folder. var ContractNumber = _contractRefactorService.GetContractNumberById(fileModel.ResourceGuid); if (fileModel.FileToUpload != null || fileModel.FileToUpload.Length != 0) { //checks whether the file extension is the correct one and the validates the fields if the file is Csv. var isfileValid = _fileService.UploadFileTypeCheck(fileModel.FileToUpload); // var filename = _fileService.FilePostWithCount($@"{documentRoot}/{ContractNumber}/WorkBreakdownStructure/", fileModel.FileToUpload); if (!isfileValid) { fileModel.IsCsv = false; } else { //Helpers.CsvValidationHelper.ChecksValidHeaderAndReadTheFile(filename, UploadMethodName.WorkBreakDownStructure); } //fileModel.UploadFileName = filename; } //soft delete the previous uploaded files _contractRefactorService.DeleteContractFileByContractGuid(fileModel.ResourceGuid, fileModel.keys); var fileEntity = _mapper.Map <ContractResourceFile>(fileModel); _contractRefactorService.InsertContractFile(fileEntity); return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!" })); } catch (Exception ex) { ModelState.AddModelError(ex.ToString(), ex.Message); return(BadRequest(ModelState)); } }
public IActionResult Add([FromForm] EmployeeBillingRatesViewModel employeeBillingRates) { try { if (employeeBillingRates.FileToUpload == null) { ModelState.AddModelError("", "Please insert the file."); return(BadRequest(ModelState)); } var isfileValid = _fileService.UploadFileTypeCheck(employeeBillingRates.FileToUpload); employeeBillingRates.CreatedOn = CurrentDateTimeHelper.GetCurrentDateTime(); employeeBillingRates.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime(); employeeBillingRates.CreatedBy = UserHelper.CurrentUserGuid(HttpContext); employeeBillingRates.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext); employeeBillingRates.IsActive = true; employeeBillingRates.IsDeleted = false; var contractNumber = _contractRefactorService.GetContractNumberById(employeeBillingRates.ContractGuid); var contractResourceFile = _contractResourceFileService.GetFilePathByResourceIdAndKeys(Core.Entities.EnumGlobal.ResourceType.EmployeeBillingRates.ToString(), employeeBillingRates.ContractGuid); if (contractResourceFile != null && (employeeBillingRates.FileToUpload != null || employeeBillingRates.FileToUpload.Length != 0)) { var filename = ""; if (!isfileValid) { var directoryPath = Path.GetDirectoryName(contractResourceFile.FilePath); filename = _fileService.FilePost($@"{documentRoot}/{contractResourceFile.FilePath}/", employeeBillingRates.FileToUpload); employeeBillingRates.IsCsv = false; filePath = $"{contractResourceFile.FilePath}/{filename}"; } else { var files = _contractRefactorService.GetFileByResourceGuid(employeeBillingRates.ContractGuid, Core.Entities.EnumGlobal.ResourceType.EmployeeBillingRates.ToString()); var relativePath = $@"{documentRoot}/{contractResourceFile.FilePath}/"; var previousFile = string.Empty; if (files != null) { previousFile = files.UploadFileName; } filename = _fileService.MoveFile(relativePath, previousFile, employeeBillingRates.FileToUpload); employeeBillingRates.IsCsv = true; var fullPath = $@"{relativePath}/{filename}"; Helpers.CsvValidationHelper.ChecksValidHeaderAndReadTheFile(fullPath, relativePath, previousFile, (Models.ViewModels.EnumGlobal.UploadMethodName)UploadMethodName.EmployeeBillingRate); filePath = $"{contractResourceFile.FilePath}/{filename}"; } employeeBillingRates.FilePath = filePath; employeeBillingRates.UploadFileName = filename; } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var contractFile = ContractsMapper.MapEmployeeBillingRatesViewModelToContractFiles(employeeBillingRates); contractFile.ResourceType = Core.Entities.EnumGlobal.ResourceType.Contract.ToString(); if (contractResourceFile != null) { contractFile.ParentId = contractResourceFile.ContractResourceFileGuid; } _contractRefactorService.CheckAndInsertContractFile(contractFile); //audit log.. var contractEntity = _contractRefactorService.GetContractEntityByContractId(contractFile.ResourceGuid); var additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Uploaded.ToString(), "Employee Billing Rates File"); string additionalInformationURl = string.Empty; string resource = string.Empty; if (contractEntity.ParentContractGuid == Guid.Empty || contractEntity.ParentContractGuid == null) { additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Contract/Details/" + contractEntity.ContractGuid); resource = string.Format("{0} </br> Contract No:{1} </br> Project No:{2} </br> File Name:{3}", "Employee Billing Rates", contractEntity.ContractNumber, contractEntity.ProjectNumber, employeeBillingRates.UploadFileName); } else { additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractEntity.ContractGuid); resource = string.Format("{0} </br> TaskOrder No:{1} </br> Project No:{2} </br> File Name:{3}", "Employee Billing Rates", contractEntity.ContractNumber, contractEntity.ProjectNumber, employeeBillingRates.UploadFileName); } AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), contractFile, resource, contractFile.ContractResourceFileGuid, UserHelper.GetHostedIp(HttpContext), "File Uploaded", Guid.Empty, "Successful", "", additionalInformation, additionalInformationURl); //end of audit log. return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!" })); } catch (Exception ex) { ModelState.AddModelError(ex.ToString(), ex.Message); return(BadRequest(ModelState)); } }
public IActionResult Add([FromBody] ContractModificationViewModel contractModificationModel) { try { List <string> filePath = new List <string>(); string validation = validateModel(contractModificationModel); if (validation != YesNoStatus.Yes.ToString()) { ModelState.AddModelError("", validation); return(BadRequest(ModelState)); } if (ModelState.IsValid) { Guid id = Guid.NewGuid(); contractModificationModel.ContractModificationGuid = id; contractModificationModel.CreatedOn = CurrentDateTimeHelper.GetCurrentDateTime(); contractModificationModel.CreatedBy = UserHelper.CurrentUserGuid(HttpContext); contractModificationModel.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime(); contractModificationModel.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext); contractModificationModel.IsActive = true; contractModificationModel.IsDeleted = false; contractModificationModel.AwardAmount = contractModificationModel.AwardAmount ?? 0; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var contractId = _contractService.GetContractIdByProjectId(contractModificationModel.ContractGuid); var parentContractNumber = _contractService.GetContractNumberById(contractId); var taskOrderContractNumber = _contractService.GetContractNumberById(contractModificationModel.ContractGuid); var taskModificationEntity = _mapper.Map <ContractModification>(contractModificationModel); taskModificationEntity.IsTaskModification = true; //added task modification through contract modification _contractModificationService.Add(taskModificationEntity); //audit log.. var additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Added.ToString(), "Task Order Mod"); var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + taskModificationEntity.ContractGuid); var resource = string.Format("{0} </br> Mod No:{1} </br> Mod Title:{2}", "Task Order Mod", taskModificationEntity.ModificationNumber, taskModificationEntity.ModificationTitle); AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), taskModificationEntity, resource, taskModificationEntity.ContractModificationGuid, UserHelper.GetHostedIp(HttpContext), "Taskorder Mod Added", Guid.Empty, "Successful", "", additionalInformationURl, additionalInformationURl); //end of log.. bool istriggered = false; var revenueGuid = SaveAndNotifyRevenueRepresentative(taskModificationEntity); if (revenueGuid != Guid.Empty) { istriggered = true; } bool isViewHistory = false; var historyCount = _revenueRecognitionService.DetailListCount(taskModificationEntity.ContractGuid, ""); if (historyCount > 0) { isViewHistory = true; } //get file info.. var contractResourceFile = _contractResourceFileService.GetFilePathByResourceIdAndKeys(ContractResourceFileKey.ContractModification.ToString(), contractModificationModel.ContractGuid); var jsonObject = new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!", revenueGuid = revenueGuid, viewHistory = isViewHistory, istriggered = istriggered, contractGuid = taskModificationEntity.ContractGuid, resourceId = taskModificationEntity.ContractModificationGuid, uploadPath = contractResourceFile.FilePath, parentId = contractResourceFile.ContractResourceFileGuid }; return(Ok(jsonObject)); } else { return(BadRequest(ModelState)); } } catch (ArgumentException ex) { ModelState.AddModelError("", ex.Message); return(BadRequestFormatter.BadRequest(this, ex)); } catch (Exception e) { ModelState.AddModelError("", e.Message); return(BadRequestFormatter.BadRequest(this, e)); } }