public IActionResult Edit([FromBody] DistributionListViewModel distributionViewModel)
        {
            try
            {
                var loggedUser   = UserHelper.CurrentUserGuid(HttpContext);
                var distribution = ObjectMapper <DistributionListViewModel, DistributionList> .Map(distributionViewModel);

                distribution.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                distribution.UpdatedBy = loggedUser;

                _distributionListService.Edit(distribution);

                _distributionListService.DeleteDistributionUserByDistributionListId(distributionViewModel.DistributionListGuid);

                //add selected users for distribution..
                AddDistributionUser(distributionViewModel, distribution, loggedUser);

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Updated !!" }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }
        public ActionResult Details(Guid id)
        {
            var contractModificationModel = new ContractModificationViewModel();

            try
            {
                var contractModificationEntity = _contractModificationService.GetDetailById(id);
                contractModificationModel = _mapper.Map <ContractModificationViewModel>(contractModificationEntity);

                var currentUser = _userService.GetUserByUserGuid(UserHelper.CurrentUserGuid(HttpContext));
                var users       = Models.ObjectMapper <User, UserViewModel> .Map(currentUser);

                ViewBag.UpdatedBy   = users.Displayname;
                ViewBag.UpdatedOn   = CurrentDateTimeHelper.GetCurrentDateTime().ToString("MM/dd/yyyy");
                ViewBag.ResourceId  = contractModificationModel.ContractModificationGuid;
                ViewBag.Resourcekey = EnumGlobal.ResourceType.ContractModification.ToString();
                //ViewBag.FilePath = string.Format(
                //               $@"{contractModificationModel.ContractNumber}\ContractModification\{contractModificationModel.ModificationNumber}-{contractModificationModel.ContractTitle}");
                //get file info..
                var contractResourceFile = _contractResourceFileService.GetFilePathByResourceIdAndKeys(ContractResourceFileKey.ChangeProposals.ToString(), contractModificationModel.ContractGuid);
                ViewBag.FilePath = contractResourceFile.FilePath;

                var resourceAttributeValues = _resourceAttributeValueService.GetResourceAttributeValueByValue(contractModificationModel.ModificationType);
                if (resourceAttributeValues != null)
                {
                    contractModificationModel.ModificationType = resourceAttributeValues.Name;
                }
                return(PartialView(contractModificationModel));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(View(contractModificationModel));
            }
        }
Esempio n. 3
0
        public IActionResult Edit([FromForm] ContractWBSViewModel contractWBS)
        {
            try
            {
                contractWBS.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                contractWBS.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                contractWBS.IsActive  = true;
                contractWBS.IsDeleted = false;
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                //var wbsEntity = _mapper.Map<ContractWBS>(contractWBS);
                //_contractWBSService.UpdateContractWBS(wbsEntity);

                //add file to contract file
                var contractFile = ContractsMapper.MapContractWBSViewModelToContractResourceFile(contractWBS);
                _contractRefactorService.UpdateContractFile(contractFile);
                //end of contract file

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Edited !!" }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(ex.ToString(), ex.Message);
                return(BadRequest(ModelState));
            }
        }
        public IActionResult Add([FromBody] DistributionListViewModel distributionViewModel)
        {
            try
            {
                var checkDuplicateDistributionTitle = _distributionListService.IsDuplicateTitle(distributionViewModel.Title);

                if (checkDuplicateDistributionTitle)
                {
                    var errorMessage = "Found duplicate distribution title..";
                    ModelState.AddModelError("", errorMessage);
                    return(Ok(new { status = false, message = errorMessage }));
                }

                var loggedUser   = UserHelper.CurrentUserGuid(HttpContext);
                var distribution = ObjectMapper <DistributionListViewModel, DistributionList> .Map(distributionViewModel);

                distribution.DistributionListGuid = Guid.NewGuid();
                distribution.IsActive             = true;
                distribution.CreatedOn            = CurrentDateTimeHelper.GetCurrentDateTime();
                distribution.CreatedBy            = loggedUser;
                distribution.UpdatedOn            = CurrentDateTimeHelper.GetCurrentDateTime();

                //add selected users for distribution..
                _distributionListService.Add(distribution);

                AddDistributionUser(distributionViewModel, distribution, loggedUser);
                return(Ok(new { status = true, message = "Successfully Updated !!" }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }
Esempio n. 5
0
        private int SaveObligationEntity(List <RevenuePerformanceObligation> obligationEntityList, Guid RevenueRecognizationGuid)
        {
            var saveObligationEntity = obligationEntityList.Where(x => x.RevenueStreamIdentifier != null).ToList();

            if (saveObligationEntity.Count() > 0)
            {
                var      loggedUser      = new Guid(HttpContext.User.Identity.Name);
                DateTime currentdatetime = CurrentDateTimeHelper.GetCurrentDateTime();
                saveObligationEntity.ForEach(x =>
                {
                    x.RevenueGuid = RevenueRecognizationGuid;
                    x.PerformanceObligationGuid = new Guid();
                    x.UpdatedBy = loggedUser;
                    x.IsDeleted = false;
                    x.IsActive  = true;
                    x.UpdatedOn = currentdatetime;
                    x.CreatedBy = loggedUser;
                    x.CreatedOn = currentdatetime;
                    if (x.RevenueOverTimePointInTime == null)
                    {
                        x.RevenueOverTimePointInTime = "";
                    }
                    if (x.SatisfiedOverTime == null)
                    {
                        x.SatisfiedOverTime = "";
                    }
                });
                return(_revenueRecognitionService.UpdatePerformanceObligation(saveObligationEntity));
            }
            return(1);
        }
Esempio n. 6
0
        public ActionResult Edit(Guid id)
        {
            var contractNoticeModel = new ContractNoticeViewModel();

            if (id != Guid.Empty)
            {
                ViewBag.noticeTypes = GetComboData("NoticeContract", "NoticeType");
                ViewBag.resolutions = GetComboData("NoticeContract", "Resolution");
                var contractNoticeEntity = _contractNoticeService.GetDetailById(id);
                contractNoticeModel = _mapper.Map <ContractNoticeViewModel>(contractNoticeEntity);
                contractNoticeModel.ContractGuid = contractNoticeEntity.ResourceGuid;
                var currentUser = _userService.GetUserByUserGuid(UserHelper.CurrentUserGuid(HttpContext));
                var users       = Models.ObjectMapper <User, UserViewModel> .Map(currentUser);

                ViewBag.UpdatedBy  = users.Displayname;
                ViewBag.UpdatedOn  = CurrentDateTimeHelper.GetCurrentDateTime().ToString("MM/dd/yyyy");
                ViewBag.ResourceId = contractNoticeEntity.ContractNoticeGuid;
                contractNoticeModel.ContractNoticeGuid = contractNoticeEntity.ContractNoticeGuid;
                ViewBag.Resourcekey             = EnumGlobal.ResourceType.Contract.ToString();
                ViewBag.ContractResourceFileKey = ContractResourceFileKey.RFI.ToString();
            }
            try
            {
                return(PartialView(contractNoticeModel));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(View(contractNoticeModel));
            }
        }
        public IActionResult Add(Guid id)
        {
            try
            {
                var viewModel = Get(id);
                ViewBag.Resourcekey   = ResourceType.ContractCloseOut.ToString();
                ViewBag.ProjectNumber = _contractService.GetProjectNumberById(id);

                Guid parentContractGuid = _contractService.GetParentContractGuidByContractGuid(id) ?? Guid.Empty;
                if (parentContractGuid != Guid.Empty)
                {
                    ViewBag.ParentProjectNumber  = _contractService.GetProjectNumberById(parentContractGuid);
                    viewModel.ParentContractGuid = parentContractGuid;
                }
                var currentUser = _userService.GetUserByUserGuid(UserHelper.CurrentUserGuid(HttpContext));
                var users       = Models.ObjectMapper <User, Northwind.Web.Infrastructure.Models.ViewModels.UserViewModel> .Map(currentUser);

                ViewBag.UpdatedBy = users.DisplayName;
                ViewBag.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime().ToString("MM/dd/yyyy");

                return(View(viewModel));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }
Esempio n. 8
0
        public IActionResult Add([FromBody] ContractQuestionaireViewModel contractQuestionaire)
        {
            try
            {
                Guid id = Guid.NewGuid();
                contractQuestionaire.ContractQuestionaireGuid = id;
                contractQuestionaire.CreatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                contractQuestionaire.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                contractQuestionaire.CreatedBy = UserHelper.CurrentUserGuid(HttpContext);
                contractQuestionaire.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                contractQuestionaire.IsActive  = true;
                contractQuestionaire.IsDeleted = false;
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var questionaireEntity = _mapper.Map <ContractQuestionaire>(contractQuestionaire);
                _contractQuestionariesService.AddContractQuestionaires(questionaireEntity);
                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!" }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(ex.ToString(), ex.Message);
                return(BadRequest(ModelState));
            }
        }
Esempio n. 9
0
        public IActionResult Edit([FromForm] EmployeeBillingRatesViewModel employeeBillingRates)
        {
            try
            {
                employeeBillingRates.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                employeeBillingRates.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                employeeBillingRates.IsActive  = true;
                employeeBillingRates.IsDeleted = false;
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                //var employeeBillingRatesEntity = _mapper.Map<EmployeeBillingRates>(employeeBillingRates);
                //_employeeBillingRatesService.UpdateEmployeeBillingRates(employeeBillingRatesEntity);

                //later added
                var file = ContractsMapper.MapEmployeeBillingRatesViewModelToContractFiles(employeeBillingRates);
                _contractRefactorService.UpdateContractFile(file);

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Edited !!" }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(ex.ToString(), ex.Message);
                return(BadRequest(ModelState));
            }
        }
Esempio n. 10
0
        public IActionResult Add([FromBody] CompanyViewModel companyViewModel)
        {
            try
            {
                var companyModel = Models.ObjectMapper <CompanyViewModel, Company> .Map(companyViewModel);

                if (_companyService.CheckDuplicates(companyModel) > 0)
                {
                    throw new ArgumentException("Duplicate value entered for either code or name !!");
                }
                Guid id = Guid.NewGuid();
                companyModel.CompanyGuid = id;
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                companyModel.CreatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                companyModel.CreatedBy = UserHelper.CurrentUserGuid(HttpContext);
                companyModel.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                companyModel.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                companyModel.IsActive  = true;
                companyModel.IsDeleted = false;
                var Company = _companyService.Add(companyModel);

                //audit log..
                var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Added.ToString(), ResourceType.Company.ToString());
                var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + "/admin/Company";

                var additionalInformationWithUri = string.Format("<a href=\"{0}\">{1}</a>", additionalInformationURl, additionalInformation);

                var resource = string.Format("{0} </br> GUID: {1} </br> Company Name: {2} </br> Company Code: {3}", ResourceType.Company.ToString(), companyModel.CompanyGuid, companyModel.CompanyName, companyModel.CompanyCode);

                AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), companyModel, resource, companyModel.CompanyGuid, UserHelper.GetHostedIp(HttpContext), "Company Added", Guid.Empty, "Successful", "", additionalInformationWithUri, additionalInformationURl);


                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!" }));
            }
            catch (ArgumentException ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
        public ActionResult Edit(Guid id)
        {
            var contractModificationModel = new ContractModificationViewModel();

            if (id != Guid.Empty)
            {
                var taskModificationEntity = _contractModificationService.GetDetailById(id);
                contractModificationModel = _mapper.Map <ContractModificationViewModel>(taskModificationEntity);

                contractModificationModel.ContractNumber =
                    _contractService.GetDetailsForProjectByContractId(contractModificationModel.ContractGuid).ContractNumber;

                contractModificationModel.ProjectNumber =
                    _contractService.GetDetailById(contractModificationModel.ContractGuid).BasicContractInfo.ProjectNumber;

                contractModificationModel.keyValuePairs = new Dictionary <string, string>();
                var contractModification = _resourceAttributeService.GetByResource(ResourceType.ContractModification.ToString());
                if (contractModification != null)
                {
                    var modificationType = contractModification.FirstOrDefault(x => x.Name.ToUpper() == "MODIFICATIONTYPE");
                    if (modificationType != null)
                    {
                        var resourcevalue = _resourceAttributeValueService.GetResourceAttributeOptionsByResourceAttributeGuid(modificationType.ResourceAttributeGuid);
                        if (resourcevalue != null)
                        {
                            contractModificationModel.keyValuePairs = resourcevalue.ToDictionary(x => x.Value, x => x.Name);
                        }
                    }
                }

                var currentUser = _userService.GetUserByUserGuid(UserHelper.CurrentUserGuid(HttpContext));
                var users       = Models.ObjectMapper <User, UserViewModel> .Map(currentUser);

                ViewBag.UpdatedBy   = users.Displayname;
                ViewBag.UpdatedOn   = CurrentDateTimeHelper.GetCurrentDateTime().ToString("MM/dd/yyyy");
                ViewBag.ResourceId  = contractModificationModel.ContractModificationGuid;
                ViewBag.Resourcekey = EnumGlobal.ResourceType.TaskOrderModification.ToString();
            }
            try
            {
                return(PartialView(contractModificationModel));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(View(contractModificationModel));
            }
        }
Esempio n. 12
0
        public IActionResult Add([FromBody] OfficeViewModel officeViewModel)
        {
            try
            {
                var officeModel = Models.ObjectMapper <OfficeViewModel, Office> .Map(officeViewModel);

                if (_officeService.CheckDuplicate(officeModel) > 0)
                {
                    var errorMessage = "Duplicate value entered for either code or name !!";
                    ModelState.AddModelError("", errorMessage);
                    return(BadRequest(ModelState));
                }
                if (ModelState.IsValid)
                {
                    Guid id = Guid.NewGuid();
                    officeModel.OfficeGuid = id;
                    officeModel.CreatedOn  = CurrentDateTimeHelper.GetCurrentDateTime();
                    officeModel.CreatedBy  = id;
                    officeModel.UpdatedOn  = CurrentDateTimeHelper.GetCurrentDateTime();
                    officeModel.UpdatedBy  = id;
                    officeModel.IsActive   = true;
                    officeModel.IsDeleted  = false;
                    _officeService.Add(officeModel);


                    //audit log..
                    var additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Added.ToString(), ResourceType.Office.ToString());
                    //var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Office/Details/" + officeModel.OfficeGuid);
                    var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + "/admin/office";

                    var additionalInformationWithUri = string.Format("<a href=\"{0}\">{1}</a>", additionalInformationURl, additionalInformation);

                    var resource = string.Format("{0} </br> GUID:{1} </br> Office Name:{2} </br> Office Code:{3}", ResourceType.Office.ToString(), officeModel.OfficeGuid, officeModel.OfficeName, officeModel.OfficeCode);

                    AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), officeModel, resource, officeModel.OfficeGuid, UserHelper.GetHostedIp(HttpContext), "Office Added", Guid.Empty, "Successful", "", additionalInformationWithUri, additionalInformationURl);


                    return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!", office = new { officeGuid = id, officeName = officeModel.OfficeName } }));
                }
                return(BadRequest(ModelState));
            }
            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 ActionResult AddUpdate(ArticleViewModel model, IFormFile file, string Submit)
        {
            if (ModelState.IsValid)
            {
                Article article = _mapper.Map <Article>(model);
                if (Request.Form.Files.Count > 0)
                {
                    var fullPhysicalFilePath = string.Concat(documentRoot, "\\Article\\Images");
                    var uniqueFileName       =
                        _fileService.SaveFile(fullPhysicalFilePath, file);

                    var relativeFilePath = Path.Combine("Article\\Images", uniqueFileName);
                    article.PrimaryMediaPath = relativeFilePath;
                }
                article.CreatedOn = model.Date;
                article.CreatedBy = UserHelper.CurrentUserGuid(HttpContext);
                article.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                article.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                if (Submit == "Publish")
                {
                    article.Status = ArticleStatus.Published;
                }
                else
                {
                    article.Status = ArticleStatus.Draft;
                }
                article.IsDeleted = false;
                if (model.Action == "Edit")
                {
                    if (Submit == "Update and Publish")
                    {
                        article.Status = ArticleStatus.Published;
                    }
                    _articleService.Update(article);
                }
                else
                {
                    _articleService.Add(article);
                }
                return(RedirectToAction("Index"));
            }
            ViewBag.ArticleTypes = GetComboData();
            return(View("AddArticle", new ArticleViewModel()));
        }
Esempio n. 15
0
        public IActionResult Edit([FromBody] OfficeViewModel officeViewModel)
        {
            try
            {
                var officeModel = Models.ObjectMapper <OfficeViewModel, Office> .Map(officeViewModel);

                if (_officeService.CheckDuplicate(officeModel) > 0)
                {
                    var errorMessage = "Duplicate value entered for either code or name !!";
                    ModelState.AddModelError("", errorMessage);
                    return(BadRequest(ModelState));
                }
                if (ModelState.IsValid)
                {
                    //                    var officeModelFromRepo = _officeService.GetOfficeDetailsById(OfficeModel.OfficeGuid);
                    officeModel.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                    officeModel.CreatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                    officeModel.UpdatedBy = Guid.NewGuid();  // later comes through session..
                    var isOfficeUpated = _officeService.Edit(officeModel);
                    if (isOfficeUpated >= 1)
                    {
                        _contractsService.UpdateAllUserByRole(officeModel.OperationManagerGuid, ContractUserRole._operationManager);
                    }
                    //audit log..
                    var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Edited.ToString(), ResourceType.Office.ToString());
                    var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + "/admin/office";

                    var additionalInformationWithUri = string.Format("<a href=\"{0}\">{1}</a>", additionalInformationURl, additionalInformation);

                    var resource = string.Format("{0} </br> GUID:{1} </br> Office Name:{2} </br> Office Code:{3}", ResourceType.Office.ToString(), officeModel.OfficeGuid, officeModel.OfficeName, officeModel.OfficeCode);

                    AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), officeModel, resource, officeModel.OfficeGuid, UserHelper.GetHostedIp(HttpContext), "Office Edited", Guid.Empty, "Successful", "", additionalInformationWithUri, additionalInformationURl);

                    return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Updated !!" }));
                }
                return(BadRequest(ModelState));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }
 public IActionResult Edit([FromForm] ContractFileViewModel fileModel)
 {
     try
     {
         fileModel.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
         fileModel.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
         fileModel.IsActive  = true;
         fileModel.IsDeleted = false;
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         var fileEntity = _mapper.Map <ContractResourceFile>(fileModel);
         _contractRefactorService.UpdateContractFile(fileEntity);
         return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Edited !!" }));
     }
     catch (Exception ex)
     {
         return(BadRequestFormatter.BadRequest(this, ex));
     }
 }
        public IActionResult Add([FromBody] ContactViewModel contactViewModel)
        {
            try
            {
                Guid id = Guid.NewGuid();
                var  customerContact = ObjectMapper <ContactViewModel, CustomerContact> .Map(contactViewModel);

                customerContact.ContactTypeGuid = contactViewModel.ContactType;
                customerContact.ContactGuid     = id;
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                customerContact.CreatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                customerContact.CreatedBy = UserHelper.CurrentUserGuid(HttpContext);
                customerContact.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                customerContact.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                customerContact.IsActive  = true;
                customerContact.IsDeleted = false;
                var CustomerContact = _customerContactService.Add(customerContact);
                var jsonObjects     = new
                {
                    contactguid         = customerContact.ContactGuid,
                    searchvalue         = customerContact.SearchValue,
                    customerguid        = customerContact.CustomerGuid,
                    customerName        = customerContact.CustomerName,
                    customerLastName    = customerContact.LastName,
                    customerPhoneNumber = customerContact.PhoneNumber,
                    fullName            = Infrastructure.Helpers.FormatHelper.FormatFullName(customerContact.FirstName, customerContact.MiddleName, customerContact.LastName)
                };
                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!", CustomerContact = jsonObjects }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Esempio n. 18
0
        private int SaveContractExtension(List <RevenueContractExtension> contractExtensions, Guid RevenueRecognizationGuid)
        {
            var saveContractExtension = contractExtensions.Where(x => x.ExtensionDate.HasValue).ToList();

            if (saveContractExtension.Count() > 0)
            {
                var      loggedUser      = new Guid(HttpContext.User.Identity.Name);
                DateTime currentdatetime = CurrentDateTimeHelper.GetCurrentDateTime();
                saveContractExtension.ForEach(x =>
                {
                    x.RevenueGuid           = RevenueRecognizationGuid;
                    x.ContractExtensionGuid = new Guid();
                    x.UpdatedOn             = currentdatetime;
                    x.UpdatedBy             = loggedUser;
                    x.IsDeleted             = false;
                    x.IsActive  = true;
                    x.UpdatedOn = currentdatetime;
                    x.CreatedBy = loggedUser;
                    x.CreatedOn = currentdatetime;
                });
                return(_revenueRecognitionService.UpdateContractExtension(saveContractExtension));
            }
            return(1);
        }
        public IActionResult Edit([FromBody] ContactViewModel contactViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                contactViewModel.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                contactViewModel.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                var customerContactdetails = _customerContactService.GetDetailsById(contactViewModel.ContactGuid);

                var contact = ObjectMapper <ContactViewModel, CustomerContact> .Map(contactViewModel);

                contact.ContactTypeGuid = contactViewModel.ContactType;
                var customerContact = _customerContactService.Edit(contact);
                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Updated !!", CustomerContact = new { SearchValue = " ", customerguid = contactViewModel.CustomerGuid, customerName = contactViewModel.CustomerName } }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Esempio n. 20
0
        private ActionResult Save(FarContractViewModel farContractViewModel)
        {
            DateTime CreatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
            Guid     CreatedBy = UserHelper.CurrentUserGuid(HttpContext);
            DateTime UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
            Guid     UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
            bool     IsDeleted = false;

            if (farContractViewModel.Questionniare != null)
            {
                _contractQuestionariesService.AddQuestionaires(farContractViewModel.Questionniare, farContractViewModel.ContractGuid, CreatedOn, CreatedBy, UpdatedOn, UpdatedBy);
            }

            //// Soft Deletes the previous FAR CONTRACT and then adds new.
            _farContractService.SoftDelete(farContractViewModel.ContractGuid);


            if (farContractViewModel.SelectedValuesList != null)
            {
                foreach (var item in farContractViewModel.SelectedValuesList)
                {
                    var farContract = new FarContract();
                    farContract.ContractGuid = farContractViewModel.ContractGuid;
                    farContract.FarContractTypeClauseGuid = new Guid(item);
                    farContract.IsDeleted = IsDeleted;
                    farContract.CreatedBy = CreatedBy;
                    farContract.CreatedOn = CreatedOn;
                    farContract.UpdatedBy = UpdatedBy;
                    farContract.UpdatedOn = UpdatedOn;
                    _farContractService.Add(farContract);
                }
            }
            //// Hard deletes the soft deleted data..
            _farContractService.Delete(farContractViewModel.ContractGuid);
            return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Updated !!" }));
        }
        public IActionResult Edit([FromForm] LaborCategoryRatesViewModel laborCategoryRates)
        {
            try
            {
                laborCategoryRates.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                laborCategoryRates.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                laborCategoryRates.IsActive  = true;
                laborCategoryRates.IsDeleted = false;
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var contractFile = ContractsMapper.MapSubcontractorBillingRatesViewModelToContractFiles(laborCategoryRates);
                _contractRefactorService.UpdateContractFile(contractFile);

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Edited !!" }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(ex.ToString(), ex.Message);
                return(BadRequest(ModelState));
            }
        }
        private Guid Post(ContractCloseOutViewModel viewModel)
        {
            Guid     currentUser              = UserHelper.CurrentUserGuid(HttpContext);
            Guid     createdBy                = UserHelper.CurrentUserGuid(HttpContext);
            Guid     updatedBy                = UserHelper.CurrentUserGuid(HttpContext);
            DateTime createdOn                = CurrentDateTimeHelper.GetCurrentDateTime();
            DateTime updatedOn                = CurrentDateTimeHelper.GetCurrentDateTime();
            var      modelData                = new List <QuestionaryAnswerViewModel>();
            var      modelSubData             = new List <QuestionaryAnswerViewModel>();
            var      projectManager           = _configuration.GetSection("ContractRepresentatives").GetValue <string>("ProjectManager");
            var      contractRepresentative   = _configuration.GetSection("ContractRepresentatives").GetValue <string>("ContracRepresentative");
            var      accountingRepresentative = _configuration.GetSection("ContractRepresentatives").GetValue <string>("AccountRepresentative");

            if (viewModel.ProjectManagerQuestions != null && viewModel.RepresentativeType == projectManager)
            {
                modelData.AddRange(viewModel.ProjectManagerQuestions.Where(x => !string.IsNullOrEmpty(x.Answer)));
            }
            if (viewModel.ContractRepresentativeQuestions != null && viewModel.RepresentativeType == contractRepresentative)
            {
                modelData.AddRange(viewModel.ContractRepresentativeQuestions.Where(x => !string.IsNullOrEmpty(x.Answer)));
            }
            if (viewModel.AccountingRepresentativeQuestions != null && viewModel.RepresentativeType == accountingRepresentative)
            {
                modelData.AddRange(viewModel.AccountingRepresentativeQuestions.Where(x => !string.IsNullOrEmpty(x.Answer)));
            }
            if (viewModel.SubQuestions != null && viewModel.RepresentativeType == projectManager)
            {
                modelSubData.AddRange(viewModel.SubQuestions.Where(x => !string.IsNullOrEmpty(x.Answer)));
            }


            foreach (var item in modelData)
            {
                string approvalStatus = "";
                if (item.Answer == "No")
                {
                    if (item.OrderNumber == 1 && item.RepresentativeType == projectManager)
                    {
                        approvalStatus = ApprovalStatus.APPROVED.ToString();
                        modelSubData   = null;
                    }
                    else
                    {
                        approvalStatus = ApprovalStatus.UNAPPROVED.ToString();
                    }
                }
                else
                {
                    approvalStatus = ApprovalStatus.APPROVED.ToString();
                }
                var contractCloseApproval = _contractCloseApprovalService.GetByNormalizedValue(approvalStatus);
                var model = new QuestionaireUserAnswer
                {
                    Answer = item.Answer,
                    ContractCloseApprovalGuid = contractCloseApproval.ContractCloseApprovalGuid,
                    ContractGuid           = viewModel.ContractGuid,
                    ManagerUserGuid        = currentUser,
                    QuestionaireMasterGuid = item.QuestionaireMasterGuid,
                    Questions          = item.Questions,
                    RepresentativeType = item.RepresentativeType,
                    Status             = contractCloseApproval.NormalizedValue,
                    Notes     = item.Notes,
                    CreatedOn = createdOn,
                    CreatedBy = createdBy,
                    UpdatedBy = updatedBy,
                    UpdatedOn = updatedOn
                };
                _questionaireUserAnswerService.Add(model);
            }
            if (modelSubData != null)
            {
                if (modelSubData.Count() > 0)
                {
                    foreach (var item in modelSubData.Where(x => x.Answer != null))
                    {
                        string approvalStatus = "";
                        if (item.Answer == "No")
                        {
                            approvalStatus = ApprovalStatus.UNAPPROVED.ToString();
                        }
                        else
                        {
                            approvalStatus = ApprovalStatus.APPROVED.ToString();
                        }
                        var contractCloseApproval = _contractCloseApprovalService.GetByNormalizedValue(approvalStatus);
                        var model = new QuestionaireUserAnswer
                        {
                            Answer = item.Answer,
                            ContractCloseApprovalGuid = contractCloseApproval.ContractCloseApprovalGuid,
                            ContractGuid           = viewModel.ContractGuid,
                            ManagerUserGuid        = currentUser,
                            QuestionaireMasterGuid = item.QuestionaireMasterGuid,
                            Questions          = item.Questions,
                            RepresentativeType = item.RepresentativeType,
                            Status             = contractCloseApproval.NormalizedValue,
                            CreatedOn          = createdOn,
                            CreatedBy          = createdBy,
                            UpdatedBy          = updatedBy,
                            UpdatedOn          = updatedOn
                        };
                        _questionaireUserAnswerService.Add(model);
                    }
                }
            }

            //For Notification
            AddNotification(viewModel);

            var savedAnswers = _questionaireUserAnswerService.GetByContractGuid(viewModel.ContractGuid);
            var resourceid   = Guid.Empty;

            if (savedAnswers.Count() > 0)
            {
                if (viewModel.RepresentativeType == projectManager)
                {
                    var projectManagerData = savedAnswers.FirstOrDefault(x => x.RepresentativeType == projectManager);
                    resourceid = projectManagerData != null ? projectManagerData.QuestionaireUserAnswerGuid : Guid.Empty;
                    Guid[] ids = new Guid[1];
                    ids[0] = viewModel.ContractGuid;
                    _contractService.Disable(ids);
                }
                else if (viewModel.RepresentativeType == contractRepresentative)
                {
                    var contractRepresentativeData = savedAnswers.FirstOrDefault(x => x.RepresentativeType == contractRepresentative);
                    resourceid = contractRepresentativeData != null ? contractRepresentativeData.QuestionaireUserAnswerGuid : Guid.Empty;
                }
                else if (viewModel.RepresentativeType == accountingRepresentative)
                {
                    var accountingRepresentativeData = savedAnswers.FirstOrDefault(x => x.RepresentativeType == accountingRepresentative);
                    if (accountingRepresentativeData != null)
                    {
                        resourceid = accountingRepresentativeData.QuestionaireUserAnswerGuid;
                        _contractService.CloseContractStatus(viewModel.ContractGuid);
                    }
                }
            }
            return(resourceid);
        }
Esempio n. 23
0
        public ActionResult SaveRevenueRecognition(RevenueRecognitionViewModel model)
        {
            try
            {
                var    loggedUser        = new Guid(HttpContext.User.Identity.Name);
                string userName          = "";
                var    loggedUserDetails = _userService.GetUserByUserGuid(loggedUser);
                if (loggedUserDetails != null)
                {
                    userName = loggedUserDetails.DisplayName;
                }
                DateTime currentdatetime             = CurrentDateTimeHelper.GetCurrentDateTime();
                string   date                        = currentdatetime.ToString("MM/dd/yyyy");
                var      recognitionEntity           = _mapper.Map <RevenueRecognition>(model);
                var      contractExtensionEntityList = _mapper.Map <List <RevenueContractExtension> >(model.ListContractExtension);
                var      obligationEntityList        = _mapper.Map <List <RevenuePerformanceObligation> >(model.ListRevenuePerformanceObligation);
                switch (model.CrudType)
                {
                case CrudType.Create:
                    recognitionEntity.CreatedOn = currentdatetime;
                    recognitionEntity.CreatedBy = loggedUser;
                    recognitionEntity.UpdatedOn = currentdatetime;
                    recognitionEntity.UpdatedBy = loggedUser;
                    recognitionEntity.IsActive  = true;
                    recognitionEntity.IsDeleted = false;
                    model.CrudType = CrudType.Edit;
                    _revenueRecognitionService.UpdateRevenueRecognition(recognitionEntity);

                    //audit log..
                    var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Added.ToString(), "Revenue Recognition");
                    var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Contract/Details/" + recognitionEntity.ContractGuid);
                    var resource = string.Format("{0} </br> GUID:{1}", "Revenue Recognition", recognitionEntity.RevenueRecognizationGuid);
                    AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), recognitionEntity, resource, recognitionEntity.RevenueRecognizationGuid, UserHelper.GetHostedIp(HttpContext), "Revenue Recognition Added", Guid.Empty, "Successful", "", additionalInformationURl, additionalInformationURl);
                    //end of log..

                    return(Ok(new { model.CrudType, updatedby = userName, updatedon = date, revenueGuid = recognitionEntity.RevenueRecognizationGuid, isnotify = false, CurrentStage = model.CurrentStage, contractGuid = model.ContractGuid }));

                case CrudType.Edit:
                    var recognitionEntitydata = _revenueRecognitionService.GetDetailsById(model.RevenueRecognizationGuid);
                    recognitionEntity.CreatedBy = recognitionEntitydata.CreatedBy;
                    recognitionEntity.CreatedOn = recognitionEntitydata.CreatedOn;
                    recognitionEntity.UpdatedBy = loggedUser;
                    recognitionEntity.UpdatedOn = currentdatetime;
                    if (!CheckAuthorization(recognitionEntity.ContractGuid, model.IsAccountRepresentive))
                    {
                        throw new Exception("Not an authorized user!!");
                    }
                    switch (model.CurrentStage)
                    {
                    case "#tab_5":
                        recognitionEntity.IsNotify    = true;
                        recognitionEntity.IsCompleted = true;
                        _contractRefactorService.InsertRevenueRecognitionGuid(recognitionEntity.RevenueRecognizationGuid, recognitionEntity.ContractGuid);
                        _contractModificationService.InsertRevenueRecognitionGuid(recognitionEntity.RevenueRecognizationGuid, recognitionEntity.ContractGuid);
                        break;

                    case "#tab_4":
                        var notificationbatch = _notificationBatchService.GetByResourceId(recognitionEntity.RevenueRecognizationGuid);
                        if (notificationbatch == null)
                        {
                            SaveAndNotifyAccountingRepresentative(recognitionEntity);
                        }
                        recognitionEntity.IsNotify = true;
                        _revenueRecognitionService.UpdateIsNotify(recognitionEntity.RevenueRecognizationGuid);
                        break;
                    }
                    _revenueRecognitionService.UpdateRevenueRecognition(recognitionEntity);

                    //audit log..
                    if (!string.IsNullOrEmpty(model.CurrentStage))
                    {
                        if (model.CurrentStage.Equals("#tab_5") || model.CurrentStage.Equals("#tab_4"))
                        {
                            additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Edited.ToString(), "Revenue Recognition");
                            additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Contract/Details/" + recognitionEntity.ContractGuid);
                            resource = string.Format("{0} </br> GUID:{1}", "Revenue Recognition", recognitionEntity.RevenueRecognizationGuid);
                            AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), recognitionEntity, resource, recognitionEntity.RevenueRecognizationGuid, UserHelper.GetHostedIp(HttpContext), "Revenue Recognition Edited", Guid.Empty, "Successful", "", additionalInformationURl, additionalInformationURl);
                        }
                    }
                    //end of log..

                    if (recognitionEntity.IsContractTermExpansion)
                    {
                        SaveContractExtension(contractExtensionEntityList, recognitionEntity.RevenueRecognizationGuid);
                    }
                    SaveObligationEntity(obligationEntityList, recognitionEntity.RevenueRecognizationGuid);
                    return(Ok(new { model.CrudType, revenueGuid = model.RevenueRecognizationGuid, updatedby = userName, updatedon = date, isnotify = true, CurrentStage = model.CurrentStage, contractGuid = model.ContractGuid }));
                }
                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!", model.CrudType }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", 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));
            }
        }
        public IActionResult Edit([FromBody] ContractModificationViewModel contractModificationModel)
        {
            try
            {
                List <string> filePath      = new List <string>();
                bool          istriggered   = false;
                bool          isViewHistory = false;

                Guid   revenueGuid = Guid.Empty;
                string validation  = validateModel(contractModificationModel);
                if (validation != YesNoStatus.Yes.ToString())
                {
                    ModelState.AddModelError("", validation);
                    return(BadRequest(ModelState));
                }

                if (ModelState.IsValid)
                {
                    if (!ModelState.IsValid)
                    {
                        return(BadRequest(ModelState));
                    }
                    var contractId              = _contractService.GetContractIdByProjectId(contractModificationModel.ContractGuid);
                    var parentContractNumber    = _contractService.GetContractNumberById(contractId);
                    var taskOrderContractNumber = _contractService.GetContractNumberById(contractModificationModel.ContractGuid);
                    //var uploadPath = string.Format(
                    // $@"{parentContractNumber}\TaskOrder\{taskOrderContractNumber}\TaskOrderModification\{contractModificationModel.ModificationTitle}-{contractModificationModel.ModificationNumber}");

                    var contractModificationEntity = _mapper.Map <ContractModification>(contractModificationModel);
                    contractModificationEntity.IsTaskModification = true;
                    contractModificationEntity.UpdatedBy          = UserHelper.CurrentUserGuid(HttpContext);
                    contractModificationEntity.UpdatedOn          = CurrentDateTimeHelper.GetCurrentDateTime();

                    // for revenue and revenue notification
                    decimal?totalPreviousAwardAmount = 0.00M;
                    decimal?actualAmount             = 0.00M;
                    var     sumofAwardAmount         = _contractModificationService.GetTotalAwardAmount(contractModificationModel.ContractGuid);
                    if (sumofAwardAmount != null)
                    {
                        totalPreviousAwardAmount = (sumofAwardAmount.AwardAmount == null ? 0.00M : sumofAwardAmount.AwardAmount);
                    }
                    var previousAwardAmount = _contractModificationService.getAwardAndFundingAmountbyId(contractModificationModel.ContractModificationGuid);

                    if (previousAwardAmount.RevenueRecognitionGuid != Guid.Empty && previousAwardAmount.RevenueRecognitionGuid != null)
                    {
                        actualAmount = contractModificationModel.AwardAmount - previousAwardAmount.AwardAmount;
                    }
                    else
                    {
                        actualAmount = contractModificationModel.AwardAmount;
                    }

                    if (actualAmount < 0)
                    {
                        actualAmount = actualAmount * (-1);
                    }
                    decimal?currentAmount = totalPreviousAwardAmount + actualAmount;

                    string contractType = _contractService.GetContractType(contractModificationModel.ContractGuid);

                    if (RevenueRecognitionHelper.IsValidForRevenueRecognitionRequest(_configuration, contractType, currentAmount, 0.00M))
                    {
                        contractModificationEntity.IsUpdated = true;
                        _contractModificationService.UpdateRevenueRecognitionGuid(contractModificationEntity.ContractModificationGuid, contractModificationEntity.AwardAmount, contractModificationEntity.FundingAmount);
                        revenueGuid = AddNewRevenueAndUpdateContractModRevenueGuid(contractModificationEntity);
                        istriggered = true;



                        var historyCount = _revenueRecognitionService.DetailListCount(contractModificationEntity.ContractGuid, "");
                        if (historyCount > 0)
                        {
                            isViewHistory = true;
                        }
                    }

                    _contractModificationService.Edit(contractModificationEntity);

                    //audit log..
                    var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Edited.ToString(), "Task Order Mod");
                    var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractModificationEntity.ContractGuid);
                    var resource = string.Format("{0} </br> Mod No:{1} </br> Mod Title:{2}", "Task Order Mod", contractModificationEntity.ModificationNumber, contractModificationEntity.ModificationTitle);
                    AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), contractModificationEntity, resource, contractModificationEntity.ContractModificationGuid, UserHelper.GetHostedIp(HttpContext), "Taskorder Mod Edited", Guid.Empty, "Successful", "", additionalInformationURl, additionalInformationURl);
                    //end of log..

                    //get file info..
                    var contractResourceFile = _contractResourceFileService.GetFilePathByResourceIdAndKeys(ContractResourceFileKey.ContractModification.ToString(), contractModificationModel.ContractGuid);

                    var jsonObject = new
                    {
                        status       = ResponseStatus.success.ToString(),
                        message      = "Successfully Updated !!",
                        revenueGuid  = revenueGuid,
                        viewHistory  = isViewHistory,
                        istriggered  = istriggered,
                        contractGuid = contractModificationEntity.ContractGuid,
                        resourceId   = contractModificationEntity.ContractModificationGuid,
                        uploadPath   = contractResourceFile.FilePath,
                        parentId     = contractResourceFile.ContractResourceFileGuid
                    };

                    return(Ok(jsonObject));
                }
                else
                {
                    return(View(contractModificationModel));
                }
            }
            catch (ArgumentException ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequestFormatter.BadRequest(this, ex));
            }
            catch (Exception ex)
            {
                ModelState.Clear();
                ModelState.AddModelError("", ex.Message);
                return(BadRequestFormatter.BadRequest(this, ex));
            }
        }
Esempio n. 26
0
        private bool SendNotification(Guid resourceId, Guid contractGuid, int currentStage)
        {
            try
            {
                var notificationModel            = new GenericNotificationViewModel();
                var notificationTemplatesDetails = new NotificationTemplatesDetail();
                var userList     = new List <User>();
                var receiverInfo = new User();
                var receiverGuid = Guid.Empty;

                notificationModel.ResourceId              = resourceId;
                notificationModel.RedirectUrl             = _configuration.GetSection("SiteUrl").Value + ("/JobRequest/Detail/" + contractGuid);
                notificationModel.NotificationTemplateKey = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction
                                                                (EnumGlobal.ResourceType.JobRequest.ToString(), EnumGlobal.CrudType.Notify.ToString());
                notificationModel.CurrentDate     = CurrentDateTimeHelper.GetCurrentDateTime();
                notificationModel.CurrentUserGuid = UserHelper.CurrentUserGuid(HttpContext);
                notificationModel.SendEmail       = true;

                var jobRequestEntity = _jobRequestService.GetDetailsForJobRequestById(contractGuid);
                var model            = ContractsMapper.MapJobRequestToViewModel(jobRequestEntity);

                var keyPersonnels = _contractRefactorService.GetKeyPersonnelByContractGuid(contractGuid);
                if (keyPersonnels?.Any() == true)
                {
                    switch (currentStage)
                    {
                    case (int)JobRequestStatus.ProjectControl:
                        var projectControls = keyPersonnels.FirstOrDefault(x => x.UserRole == ContractUserRole._projectControls);
                        if (projectControls != null)
                        {
                            receiverGuid = projectControls.UserGuid;
                        }
                        break;

                    case (int)JobRequestStatus.ProjectManager:
                        var projectManager = keyPersonnels.FirstOrDefault(x => x.UserRole == ContractUserRole._projectManager);
                        if (projectManager != null)
                        {
                            receiverGuid = projectManager.UserGuid;
                        }
                        break;

                    case (int)JobRequestStatus.Accounting:
                        var accountRepresentative = keyPersonnels.FirstOrDefault(x => x.UserRole == ContractUserRole._accountRepresentative);
                        if (accountRepresentative != null)
                        {
                            receiverGuid = accountRepresentative.UserGuid;
                        }
                        break;
                    }

                    receiverInfo = _userService.GetUserByUserGuid(receiverGuid);
                    if (receiverInfo != null)
                    {
                        userList.Add(receiverInfo);
                        notificationModel.IndividualRecipients = userList;
                    }

                    var keyList = "<ul>";
                    foreach (var person in keyPersonnels)
                    {
                        keyList += "<li>" + person.User.DisplayName + " (" + person.UserRole + ")" + "</li>";
                    }
                    keyList += "</li>";
                    StringBuilder additionalUser = new StringBuilder(keyList);

                    notificationTemplatesDetails.ContractNumber   = model.BasicContractInfo.ContractNumber;
                    notificationTemplatesDetails.AwardingAgency   = model.CustomerInformation.AwardingAgencyOfficeName;
                    notificationTemplatesDetails.FundingAgency    = model.CustomerInformation.FundingAgencyOfficeName;
                    notificationTemplatesDetails.ProjectNumber    = model.BasicContractInfo.ProjectNumber;
                    notificationTemplatesDetails.ContractTitle    = model.BasicContractInfo.ContractTitle;
                    notificationTemplatesDetails.Description      = model.BasicContractInfo.Description;
                    notificationTemplatesDetails.AdditionalUser   = additionalUser.ToString();
                    notificationTemplatesDetails.Status           = "";
                    notificationModel.NotificationTemplatesDetail = notificationTemplatesDetails;
                    _genericNotificationService.AddNotificationMessage(notificationModel);
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                var userGuid = UserHelper.CurrentUserGuid(HttpContext);
                EventLogHelper.Error(_eventLogger, new EventLog
                {
                    EventGuid   = Guid.NewGuid(),
                    Action      = "Index",
                    Application = "ESS",
                    EventDate   = DateTime.UtcNow,
                    Message     = ex.Message,
                    Resource    = ResourceType.Contract.ToString(),
                    StackTrace  = ex.StackTrace,
                    UserGuid    = userGuid
                });
                return(false);
            }
        }
        private void AddDistributionUser(DistributionListViewModel distributionViewModel, DistributionList distribution,
                                         Guid loggedUser)
        {
            List <DistributionUser> distributionUsers = new List <DistributionUser>();

            //if select all is selected in grid..
            if (distributionViewModel.UserSelection != null)
            {
                if (distributionViewModel.UserSelection.SelectedAll)
                {
                    var users = _userService.GetUsersData(string.Empty)
                                .Where(x => !string.IsNullOrEmpty(x.Firstname) && !string.IsNullOrEmpty(x.WorkEmail));

                    var usersExceptExcludelist = users.Where(x =>
                                                             !distributionViewModel.UserSelection.ExcludeList.Select(y => y.UserGuid).Contains(x.UserGuid));

                    if (usersExceptExcludelist.Count() > 0)
                    {
                        foreach (var user in usersExceptExcludelist)
                        {
                            var distributionUser = new DistributionUser()
                            {
                                DistributionUserGuid = Guid.NewGuid(),
                                DistributionListGuid = distribution.DistributionListGuid,
                                UserGuid             = user.UserGuid,
                                CreatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                CreatedBy            = loggedUser,
                                UpdatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                UpdatedBy            = loggedUser
                            };
                            distributionUsers.Add(distributionUser);
                        }
                    }

                    //see if user has been selected from multi select drop down control...
                    if (distributionViewModel.SelectedUsers.Count() > 0)
                    {
                        foreach (var user in distributionViewModel.SelectedUsers)
                        {
                            var distributionUser = new DistributionUser()
                            {
                                DistributionUserGuid = Guid.NewGuid(),
                                DistributionListGuid = distribution.DistributionListGuid,
                                UserGuid             = user.UserGuid,
                                CreatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                CreatedBy            = loggedUser,
                                UpdatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                UpdatedBy            = loggedUser
                            };
                            distributionUsers.Add(distributionUser);
                        }
                    }


                    // finally save the distinct user..
                    var distributionUniqueUser = distributionUsers.GroupBy(p => p.UserGuid)
                                                 .Select(g => g.FirstOrDefault())
                                                 .ToList();;
                    if (distributionUniqueUser.Count() > 0)
                    {
                        foreach (var user in distributionUniqueUser)
                        {
                            var distributionUser = new DistributionUser()
                            {
                                DistributionUserGuid = Guid.NewGuid(),
                                DistributionListGuid = distribution.DistributionListGuid,
                                UserGuid             = user.UserGuid,
                                CreatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                CreatedBy            = loggedUser,
                                UpdatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                UpdatedBy            = loggedUser
                            };
                            _distributionListService.AddDistributionUser(distributionUser);
                        }
                    }
                }
                // select all is not  selected in grid..
                else
                {
                    if (distributionViewModel.UserSelection.IncludeList.Count() > 0)
                    {
                        foreach (var user in distributionViewModel.UserSelection.IncludeList)
                        {
                            var distributionUser = new DistributionUser()
                            {
                                DistributionUserGuid = Guid.NewGuid(),
                                DistributionListGuid = distribution.DistributionListGuid,
                                UserGuid             = user.UserGuid,
                                CreatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                CreatedBy            = loggedUser,
                                UpdatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                UpdatedBy            = loggedUser
                            };
                            distributionUsers.Add(distributionUser);
                        }
                    }
                    //see if user has been selected from multi select drop down control...
                    if (distributionViewModel.SelectedUsers.Count() > 0)
                    {
                        foreach (var user in distributionViewModel.SelectedUsers)
                        {
                            var distributionUser = new DistributionUser()
                            {
                                DistributionUserGuid = Guid.NewGuid(),
                                DistributionListGuid = distribution.DistributionListGuid,
                                UserGuid             = user.UserGuid,
                                CreatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                CreatedBy            = loggedUser,
                                UpdatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                UpdatedBy            = loggedUser
                            };
                            distributionUsers.Add(distributionUser);
                        }
                    }
                    // finally save the distinct user..
                    var distributionUniqueUser = distributionUsers.GroupBy(p => p.UserGuid)
                                                 .Select(g => g.FirstOrDefault())
                                                 .ToList();
                    if (distributionUniqueUser.Count() > 0)
                    {
                        foreach (var user in distributionUniqueUser)
                        {
                            var distributionUser = new DistributionUser()
                            {
                                DistributionUserGuid = Guid.NewGuid(),
                                DistributionListGuid = distribution.DistributionListGuid,
                                UserGuid             = user.UserGuid,
                                CreatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                CreatedBy            = loggedUser,
                                UpdatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                                UpdatedBy            = loggedUser
                            };
                            _distributionListService.AddDistributionUser(distributionUser);
                        }
                    }
                }
            }
            else
            {
                if (distributionViewModel.SelectedUsers.Count() > 0)
                {
                    foreach (var user in distributionViewModel.SelectedUsers)
                    {
                        var distributionUser = new DistributionUser()
                        {
                            DistributionUserGuid = Guid.NewGuid(),
                            DistributionListGuid = distribution.DistributionListGuid,
                            UserGuid             = user.UserGuid,
                            CreatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                            CreatedBy            = loggedUser,
                            UpdatedOn            = CurrentDateTimeHelper.GetCurrentDateTime(),
                            UpdatedBy            = loggedUser
                        };
                        _distributionListService.AddDistributionUser(distributionUser);
                    }
                }
            }
        }
Esempio n. 28
0
        //[ValidateAntiForgeryToken]
        public IActionResult Edit([FromBody] RegionViewModel regionViewModel)
        {
            try
            {
                var regionModel = Models.ObjectMapper <RegionViewModel, Region> .Map(regionViewModel);

                if (_regionService.CheckDuplicates(regionModel) > 0)
                {
                    ModelState.AddModelError("", "Duplicate value entered for either code or name!!");
                    return(BadRequest(ModelState));
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                regionModel.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                regionModel.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                var regiondetails = _regionService.GetById(regionModel.RegionGuid);
                regionModel.IsActive  = regiondetails.IsActive;
                regionModel.IsDeleted = regiondetails.IsDeleted;
                regionModel.CreatedBy = regiondetails.CreatedBy;
                regionModel.CreatedOn = regiondetails.CreatedOn;
                _regionService.Edit(regionModel);
                RegionUserRoleMapping regionUserRoleMapping = new RegionUserRoleMapping();
                regionUserRoleMapping.RegionGuid = regionViewModel.RegionGuid;
                regionUserRoleMapping.Keys       = "Region";


                if (regionViewModel.BusinessDevelopmentRegionalManager != null)
                {
                    regionUserRoleMapping.RegionUserRoleMappingGuid = Guid.NewGuid();
                    regionUserRoleMapping.UserGuid = regionViewModel.BusinessDevelopmentRegionalManager;
                    regionUserRoleMapping.RoleType = ContractUserRole._bdregionalManager;
                    //_regionService.AddUpdateManager(regionUserRoleMapping);
                    _contractsService.UpdateAllUserByRole(regionViewModel.BusinessDevelopmentRegionalManager, ContractUserRole._bdregionalManager);
                }

                if (regionViewModel.HSRegionalManager != null)
                {
                    regionUserRoleMapping.RegionUserRoleMappingGuid = Guid.NewGuid();
                    regionUserRoleMapping.UserGuid = regionViewModel.HSRegionalManager;
                    regionUserRoleMapping.RoleType = ContractUserRole._hsregionalManager;
                    //_regionService.AddUpdateManager(regionUserRoleMapping);
                    _contractsService.UpdateAllUserByRole(regionViewModel.HSRegionalManager, ContractUserRole._hsregionalManager);
                }

                if (regionViewModel.DeputyRegionalManager != null)
                {
                    regionUserRoleMapping.RegionUserRoleMappingGuid = Guid.NewGuid();
                    regionUserRoleMapping.UserGuid = regionViewModel.DeputyRegionalManager;
                    regionUserRoleMapping.RoleType = ContractUserRole._deputyregionalManager;
                    //_regionService.AddUpdateManager(regionUserRoleMapping);
                    _contractsService.UpdateAllUserByRole(regionViewModel.DeputyRegionalManager, ContractUserRole._deputyregionalManager);
                }
                if (regionViewModel.RegionalManager != null)
                {
                    regionUserRoleMapping.RegionUserRoleMappingGuid = Guid.NewGuid();
                    regionUserRoleMapping.UserGuid = regionViewModel.RegionalManager;
                    regionUserRoleMapping.RoleType = ContractUserRole._regionalManager;
                    //_regionService.AddUpdateManager(regionUserRoleMapping);
                    _contractsService.UpdateAllUserByRole(regionViewModel.RegionalManager, ContractUserRole._regionalManager);
                }
                //audit log..
                var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Edited.ToString(), ResourceType.Region.ToString());
                var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + "/admin/Region";

                var additionalInformationWithUri = string.Format("<a href=\"{0}\">{1}</a>", additionalInformationURl, additionalInformation);

                var resource = string.Format("{0} </br> GUID: {1} </br> Region Name: {2} </br> Region Code: {3}", ResourceType.Region.ToString(), regionModel.RegionGuid, regionModel.RegionName, regionModel.RegionCode);

                AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), regionModel, resource, regionModel.RegionGuid, UserHelper.GetHostedIp(HttpContext), "Region Edited", Guid.Empty, "Successful", "", additionalInformationWithUri, additionalInformationURl);

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Updated !!" }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Esempio n. 29
0
        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));
            }
        }
        private bool AddNotificationMessage(ContractNotificationModel contractModel)
        {
            try
            {
                var     notificationModel            = new GenericNotificationViewModel();
                var     notificationTemplatesDetails = new NotificationTemplatesDetail();
                var     userList        = new List <User>();
                var     receiverInfo    = new User();
                Guid?   receiverGuid    = Guid.Empty;
                decimal thresholdAmount = 0.00M;

                notificationModel.ResourceId              = contractModel.ContractGuid;
                notificationModel.RedirectUrl             = _configuration.GetSection("SiteUrl").Value + ("/contract/Details/" + contractModel.ContractGuid);
                notificationModel.NotificationTemplateKey = contractModel.key;
                notificationModel.CurrentDate             = CurrentDateTimeHelper.GetCurrentDateTime();
                notificationModel.CurrentUserGuid         = UserHelper.CurrentUserGuid(HttpContext);
                notificationModel.SendEmail = true;


                var keyPersonnels = _contractService.GetKeyPersonnelByContractGuid(contractModel.ContractGuid);

                if (keyPersonnels?.Any() == true)
                {
                    receiverGuid = keyPersonnels.FirstOrDefault(x => x.UserRole == ContractUserRole._contractRepresentative)?.UserGuid;
                    if (receiverGuid != Guid.Empty)
                    {
                        thresholdAmount = RevenueRecognitionHelper.GetAmountByContractType(_configuration, contractModel.ContractType);

                        receiverInfo = _userService.GetUserByUserGuid(receiverGuid ?? Guid.Empty);

                        var    resourcevalue = _resourceAttributeValueService.GetResourceAttributeValueByValue(contractModel.ContractType);
                        string contracttype  = string.Empty;
                        if (resourcevalue != null)
                        {
                            contracttype = resourcevalue.Name;
                        }

                        if (receiverInfo != null)
                        {
                            userList.Add(receiverInfo);
                            notificationModel.IndividualRecipients = userList;
                        }

                        var keyList = "<ul>";
                        keyList += "<li>" + receiverInfo.DisplayName + " (" + receiverInfo.JobTitle + ")" + "</li>";
                        StringBuilder additionalUser = new StringBuilder(keyList);

                        notificationTemplatesDetails.ContractNumber   = contractModel.ContractNumber;
                        notificationTemplatesDetails.Title            = contractModel.ContractTitle;
                        notificationTemplatesDetails.ContractType     = contracttype;
                        notificationTemplatesDetails.ContractTitle    = contractModel.ContractTitle;
                        notificationTemplatesDetails.ProjectNumber    = contractModel.ProjectNumber;
                        notificationTemplatesDetails.AdditionalUser   = additionalUser.ToString();
                        notificationTemplatesDetails.ThresholdAmount  = thresholdAmount;
                        notificationTemplatesDetails.Status           = "";
                        notificationModel.NotificationTemplatesDetail = notificationTemplatesDetails;
                        _genericNotificationService.AddNotificationMessage(notificationModel);
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                var userGuid = UserHelper.CurrentUserGuid(HttpContext);
                EventLogHelper.Error(_eventLogger, new EventLog
                {
                    EventGuid   = Guid.NewGuid(),
                    Action      = "Index",
                    Application = "ESS",
                    EventDate   = DateTime.UtcNow,
                    Message     = ex.Message,
                    Resource    = ResourceType.Contract.ToString(),
                    StackTrace  = ex.StackTrace,
                    UserGuid    = userGuid
                });
                return(false);
            }
        }