コード例 #1
0
        public ActionResult Add(Guid contractGuid)
        {
            var contractModificationModel = new ContractModificationViewModel();

            try
            {
                var contractInfo = _contractsService.GetOnlyRequiredContractData(contractGuid);
                contractModificationModel.ContractGuid   = contractGuid;
                contractModificationModel.ContractTitle  = contractInfo.ContractTitle;
                contractModificationModel.ProjectNumber  = contractInfo.ProjectNumber;
                contractModificationModel.ContractNumber = contractInfo.ContractNumber;
                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);
                        }
                    }
                }
                ViewBag.Resourcekey = EnumGlobal.ResourceType.ContractModification.ToString();
                return(PartialView(contractModificationModel));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(View(contractModificationModel));
            }
        }
コード例 #2
0
        private bool AddNotification(ContractCloseOutViewModel viewModel)
        {
            if (!string.IsNullOrEmpty(viewModel.RepresentativeType))
            {
                var projectManager           = _configuration.GetSection("ContractRepresentatives").GetValue <string>("ProjectManager");
                var contractRepresentative   = _configuration.GetSection("ContractRepresentatives").GetValue <string>("ContracRepresentative");
                var accountingRepresentative = _configuration.GetSection("ContractRepresentatives").GetValue <string>("AccountRepresentative");

                string contractClosekey = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction(EnumGlobal.ResourceType.ContractCloseOut.ToString(),
                                                                                                          EnumGlobal.CrudType.Notify.ToString());
                var contractdetails        = _contractService.GetOnlyRequiredContractData(viewModel.ContractGuid);
                var representativeToNotify = string.Empty;
                if (viewModel.RepresentativeType.ToUpper() == projectManager)
                {
                    representativeToNotify = contractRepresentative;
                }
                else if (viewModel.RepresentativeType.ToUpper() == contractRepresentative)
                {
                    representativeToNotify = accountingRepresentative;
                }
                else
                {
                    representativeToNotify = string.Empty;
                }
                if (!string.IsNullOrEmpty(representativeToNotify))
                {
                    var notification = new ContractNotificationModel
                    {
                        ContractGuid           = viewModel.ContractGuid,
                        ContractNumber         = contractdetails.ContractNumber,
                        ProjectNumber          = contractdetails.ProjectNumber,
                        ContractRepresentative = viewModel.RepresentativeType,
                        ContractTitle          = contractdetails.ContractTitle,
                        ContractType           = contractdetails.ContractType,
                        key         = contractClosekey,
                        Description = contractdetails.Description
                    };
                    AddNotificationMessage(notification);
                }
            }
            return(true);
        }
コード例 #3
0
        private bool AddNotificationMessage(RevenueRecognition model)
        {
            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;
                string  key             = string.Empty;
                string  contractNumber  = string.Empty;
                string  taskorderNumber = string.Empty;

                var contractdetails = _contractRefactorService.GetOnlyRequiredContractData(model.ContractGuid);
                notificationModel.RedirectUrl = _configuration.GetSection("SiteUrl").Value + ("/contract/Details/" + model.ContractGuid);
                if (contractdetails != null)
                {
                    if (contractdetails.ParentContractGuid != null)
                    {
                        if (contractdetails.ParentContractGuid != Guid.Empty)
                        {
                            key = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction(EnumGlobal.ResourceType.RevenueRecognition.ToString(),
                                                                                                  EnumGlobal.ResourceAction.TaskOrderReview.ToString());
                            var parentcontractEntity = _contractRefactorService.GetOnlyRequiredContractData(contractdetails.ParentContractGuid);
                            contractNumber  = parentcontractEntity.ContractNumber;
                            taskorderNumber = contractdetails.ContractNumber;
                            notificationModel.RedirectUrl = _configuration.GetSection("SiteUrl").Value + ("/project/Details/" + model.ContractGuid);
                        }
                        else
                        {
                            key = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction(EnumGlobal.ResourceType.RevenueRecognition.ToString(),
                                                                                                  EnumGlobal.ResourceAction.ContractReview.ToString());
                        }
                    }
                    else
                    {
                        key = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction(EnumGlobal.ResourceType.RevenueRecognition.ToString(),
                                                                                              EnumGlobal.ResourceAction.ContractReview.ToString());
                    }

                    notificationModel.ResourceId = model.ContractGuid;
                    notificationModel.NotificationTemplateKey = key;
                    notificationModel.CurrentDate             = CurrentDateTimeHelper.GetCurrentDateTime();
                    notificationModel.CurrentUserGuid         = UserHelper.CurrentUserGuid(HttpContext);
                    notificationModel.SendEmail = true;


                    var keyPersonnels = _contractRefactorService.GetKeyPersonnelByContractGuid(model.ContractGuid);

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

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

                            var    resourcevalue = _resourceAttributeValueService.GetResourceAttributeValueByValue(model.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   = contractNumber;
                            notificationTemplatesDetails.TaskOrderNumber  = taskorderNumber;
                            notificationTemplatesDetails.Title            = contractdetails.ContractTitle;
                            notificationTemplatesDetails.ContractType     = contracttype;
                            notificationTemplatesDetails.ContractTitle    = contractdetails.ContractTitle;
                            notificationTemplatesDetails.ProjectNumber    = contractdetails.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);
            }
        }