public ActionResult Disable([FromBody] Guid[] ids)
        {
            try
            {
                _companyService.Disable(ids);

                //audit log..
                foreach (var id in ids)
                {
                    var companyModel             = _companyService.GetDetailsById(id);
                    var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Disabled.ToString(), ResourceType.Company.ToString().ToLower());
                    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), id, resource, companyModel.CompanyGuid, UserHelper.GetHostedIp(HttpContext), "Company Disabled", Guid.Empty, "Successful", "", additionalInformationWithUri, additionalInformationURl);
                }

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Disabled !!" }));
            }
            catch (Exception ex)
            {
                return(BadRequestFormatter.BadRequest(this, ex));;
            }
        }
        public ActionResult Delete([FromBody] Guid[] ids)
        {
            try
            {
                foreach (var id in ids)
                {
                    //audit log..
                    var companyModel = _companyService.GetDetailsById(id);
                    if (companyModel != null)
                    {
                        _companyService.DeleteById(id);

                        var additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Deleted.ToString(), ResourceType.Company.ToString().ToLower());

                        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  Deleted", Guid.Empty, "Successful", "", additionalInformation, "");
                    }
                }


                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Deleted !!" }));
            }
            catch (Exception ex)
            {
                return(BadRequestFormatter.BadRequest(this, ex));;
            }
        }
示例#3
0
        public IActionResult Enable([FromBody] Guid[] ids)
        {
            try
            {
                _jobRequestService.Enable(ids);

                //audit log..
                foreach (var id in ids)
                {
                    var jobRequestModel          = _jobRequestService.GetJobRequestEntityByJobRequestId(id);
                    var contractEntity           = _contractRefactorService.GetContractEntityByContractId(jobRequestModel.ContractGuid);
                    var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Enabled.ToString(), ResourceType.JobRequest.ToString());
                    var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/jobRequest/Detail/" + jobRequestModel.ContractGuid);

                    //var resource = string.Empty;
                    //if (contractEntity.ParentContractGuid == Guid.Empty || contractEntity.ParentContractGuid == null)
                    //    resource = string.Format("{0} </br> GUID:{1} </br> Contract No:{2} </br> Project No:{3} </br> Contract Title:{4}", ResourceType.JobRequest.ToString(), jobRequestModel.JobRequestGuid, contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle);
                    //else
                    //    resource = string.Format("{0} </br> GUID:{1} </br> TaskOrder  No:{2} </br> Project No:{3} </br> TaskOrder Title:{4}", ResourceType.JobRequest.ToString(), jobRequestModel.JobRequestGuid, contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle);

                    var resource = string.Format("{0} </br> Project No :{1} Title:{2}", "Job Request", contractEntity.ProjectNumber, contractEntity.ContractTitle);
                    AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), id, resource, contractEntity.ContractGuid, UserHelper.GetHostedIp(HttpContext), "Job Request Enabled", Guid.Empty, "Successful", "", additionalInformationURl, additionalInformationURl);
                }
                //end of log..

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Enabled !!" }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }
        public IActionResult Enable([FromBody] Guid[] ids)
        {
            try
            {
                _contractModificationService.Enable(ids);

                //audit log..
                foreach (var id in ids)
                {
                    var contractModificationEntity = _contractModificationService.GetDetailById(id);
                    var additionalInformation      = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Enabled.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 Enabled", Guid.Empty, "Successful", "", additionalInformationURl, additionalInformationURl);
                }
                //end of log..

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Enabled !!" }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }
        public IActionResult Delete([FromBody] Guid[] ids)
        {
            try
            {
                foreach (var id in ids)
                {
                    //audit log..
                    var officeModel = _officeService.GetDetailById(id);
                    if (officeModel != null)
                    {
                        var additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Deleted.ToString(), ResourceType.Office.ToString().ToLower());

                        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  Deleted", Guid.Empty, "Successful", "", additionalInformation, "");

                        _officeService.DeleteById(id);
                    }
                }
                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Deleted !!" }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }
        public IActionResult Enable([FromBody] Guid[] ids)
        {
            try
            {
                _officeService.Enable(ids);

                //audit log..
                foreach (var id in ids)
                {
                    var officeModel              = _officeService.GetDetailById(id);
                    var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Enabled.ToString(), ResourceType.Office.ToString().ToLower());
                    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), id, resource, officeModel.OfficeGuid, UserHelper.GetHostedIp(HttpContext), "Office Enabled", Guid.Empty, "Successful", "", additionalInformationWithUri, additionalInformationURl);
                }

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Enabled !!" }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }
        public IActionResult Delete([FromBody] Guid[] ids)
        {
            try
            {
                var updatedBy = UserHelper.CurrentUserGuid(HttpContext);
                foreach (var id in ids)
                {
                    _farClauseService.Delete(id, updatedBy);

                    //audit log..
                    var farClauseEntity       = _farClauseService.GetById(id);
                    var additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Deleted.ToString(), "Far Clause");

                    string[] resourceTitles = { "ResourceTitle", "GUID", "Number", "Title" };
                    string[] resourceValues = { "Far Clause", farClauseEntity.FarClauseGuid.ToString(), farClauseEntity.Number, farClauseEntity.Title };
                    var      resource       = FormatHelper.AuditLogResourceFormat(resourceTitles, resourceValues);

                    AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), farClauseEntity, resource, farClauseEntity.FarClauseGuid, UserHelper.GetHostedIp(HttpContext), "Far Clause Deleted", Guid.Empty, "Successful", "", additionalInformation, "");
                    //end of log..
                }

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Deleted !!" }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }
示例#8
0
        public async Task <ActionResult> Index(LoginRequest request)
        {
            ViewBag.Method = "POST";
            try
            {
                var data = new { UserName = request.Username };
                var user = _userService.Authenticate(_adContext, request.Username, request.Password);
                if (user != null)
                {
                    AuditLogHandler.InfoLog(_logger, user.DisplayName, user.UserGuid, data, "Login", Guid.Empty, UserHelper.GetHostedIp(HttpContext), "Login to application", Guid.Empty, "Login Successful", "Provided correct credientials", "", "");

                    return(await SetClaimsAndLogin(user));
                }
                else
                {
                    AuditLogHandler.InfoLog(_logger, request.Username, Guid.Empty, data, "Login", Guid.Empty, UserHelper.GetHostedIp(HttpContext), "Login to application", Guid.Empty, "Login Unsuccessful", "Provided incorrect credientials", "", "");

                    ModelState.AddModelError("", "Invalid username or password.");
                    return(View("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View("Index"));
            }
        }
示例#9
0
        public async Task <ActionResult> Logout()
        {
            var data = new { UserName = User.FindFirst("fullName").Value };

            AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), data, "", Guid.Empty, UserHelper.GetHostedIp(HttpContext), "Logout", Guid.Empty, "Logout Successful", "", "", "");

            await HttpContext.SignOutAsync();

            return(Redirect("~/Login"));
        }
        public IActionResult Add([FromBody] CustomerViewModel customerViewModel)
        {
            try
            {
                // Mapping Done

                Customer customer = new Customer();
                customer = ObjectMapper <CustomerViewModel, Customer> .Map(customerViewModel);

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                Guid id = Guid.NewGuid();
                customer.CustomerGuid = id;
                customer.CreatedOn    = DateTime.Now;
                customer.CreatedBy    = id;
                customer.UpdatedOn    = DateTime.Now;
                customer.UpdatedBy    = id;
                customer.IsActive     = true;
                customer.IsDeleted    = false;
                var CustomerName = customer.CustomerName;
                if (string.IsNullOrEmpty(customer.CustomerCode))
                {
                    customer.CustomerCode = "N/A";
                }
                else
                {
                    if (_customerService.CheckDuplicates(customer) > 0)
                    {
                        ModelState.AddModelError("", "Duplicate value entered for either code or name !!");
                        return(BadRequest(ModelState));
                    }
                }
                _customerService.Add(customer);

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

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

                var resource = string.Format("{0} </br> GUID: {1} </br> Customer Name: {2} </br> Customer Code: {3}", ResourceType.Customer.ToString(), customer.CustomerGuid, customer.CustomerName, customer.CustomerCode);

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

                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!", customer = new { customerGuid = customer.CustomerGuid, customerName = customer.CustomerName } }));
            }
            catch (ArgumentException ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
示例#11
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([FromBody] CustomerViewModel customerViewModel)
        {
            try
            {
                // Mapping Done
                Customer customer     = new Customer();
                var      customerType = _customerTypeService.GetCustomerTypeByGuid(customerViewModel.CustomerTypeGuid);
                customer = ObjectMapper <CustomerViewModel, Customer> .Map(customerViewModel);

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                if (customer.CustomerCode != "N/A" && customerType == EnumGlobal.CustomerType.Federal.ToString())
                {
                    if (_customerService.CheckDuplicates(customer) > 0)
                    {
                        ModelState.AddModelError("", "Duplicate value entered for either code or name !!");
                        return(BadRequest(ModelState));
                    }
                }
                if (string.IsNullOrEmpty(customer.CustomerCode))
                {
                    customer.CustomerCode = "N/A";
                }
                //var customerdetails = _customerService.GetCustomerById(customer.CustomerGuid);
                customer.UpdatedOn = DateTime.Now;
                customer.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);

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

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

                var resource = string.Format("{0} </br> GUID: {1} </br> Customer Name: {2} </br> Customer Code: {3}", ResourceType.Customer.ToString(), customer.CustomerGuid, customer.CustomerName, customer.CustomerCode);

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

                _customerService.Edit(customer);
                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Updated !!" }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequestFormatter.BadRequest(this, ex));
            }
        }
示例#13
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));
            }
        }
示例#14
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));
            }
        }
示例#15
0
        public IActionResult Add([FromBody] FarContractTypeViewModel farContractTypeViewModel)
        {
            try
            {
                var farContractTypeModel = Models.ObjectMapper <FarContractTypeViewModel, FarContractType> .Map(farContractTypeViewModel);

                farContractTypeModel.UpdatedBy           = UserHelper.CurrentUserGuid(HttpContext);
                farContractTypeModel.IsDeleted           = false;
                farContractTypeModel.FarContractTypeGuid = Guid.NewGuid();
                if (_farContractTypeService.CheckDuplicate(farContractTypeModel) > 0)
                {
                    throw new ArgumentException("Duplicate value entered for code !!");
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                _farContractTypeService.Add(farContractTypeModel);
                //audit log..
                var      additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Added.ToString(), ResourceType.FarContractType.ToString());
                var      additionalInformationURl = _configuration.GetSection("SiteUrl").Value + "/admin/FarContractType";
                string[] resourceTitles           = { "Code", "Title" };
                string[] resourceValues           = { farContractTypeModel.Code, farContractTypeModel.Title };
                var      resource = FormatHelper.AuditLogResourceFormat(resourceTitles, resourceValues);
                AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), farContractTypeModel, resource, Guid.Empty, UserHelper.GetHostedIp(HttpContext), "FarContractType Added", Guid.Empty, "Successful", "", additionalInformation, 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));
            }
        }
示例#16
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));
            }
        }
        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));
            }
        }
示例#18
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));
            }
        }
示例#19
0
        public ActionResult Add(JobRequestViewModel jobRequestViewModel)
        {
            try
            {
                List <string> selectionOfCompanies = new List <string>();

                JobRequest jobRequest = new JobRequest();
                jobRequest = ContractsMapper.MapViewModelToJobRequest(jobRequestViewModel);

                if (jobRequestViewModel.CompanySelected != null && jobRequestViewModel.CompanySelected.Count > 0)
                {
                    foreach (var name in jobRequestViewModel.CompanySelected)
                    {
                        selectionOfCompanies.Add(name);
                    }
                    jobRequest.Companies = string.Join(",", selectionOfCompanies);
                }
                Guid id = Guid.NewGuid();
                jobRequest.JobRequestGuid = id;
                jobRequest.CreatedOn      = DateTime.Now;
                jobRequest.CreatedBy      = UserHelper.CurrentUserGuid(HttpContext);
                jobRequest.UpdatedOn      = DateTime.Now;
                jobRequest.UpdatedBy      = UserHelper.CurrentUserGuid(HttpContext);
                jobRequest.IsActive       = true;
                jobRequest.IsDeleted      = false;
                jobRequest.Status         = (int)JobRequestStatus.ProjectControl;
                _jobRequestService.Add(jobRequest);

                SendNotification(jobRequest.JobRequestGuid, jobRequest.ContractGuid, jobRequest.Status);

                //audit log..
                var contractEntity           = _contractRefactorService.GetContractEntityByContractId(jobRequest.ContractGuid);
                var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Added.ToString(), ResourceType.JobRequest.ToString());
                var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/jobRequest/Detail/" + jobRequest.ContractGuid);
                var resource = string.Format("{0} </br> Project No :{1} Title:{2}", "Job Request", contractEntity.ProjectNumber, contractEntity.ContractTitle);
                AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), jobRequest.BasicContractInfo, resource, jobRequest.JobRequestGuid, UserHelper.GetHostedIp(HttpContext), "Job Request Added", Guid.Empty, "Successful", "", additionalInformationURl, additionalInformationURl);
                //end of log..


                _contractRefactorService.UpdateContractUsers(jobRequest.Contracts.ContractUserRole);
                _contractRefactorService.UpdateProjectNumberByGuid(jobRequest.Contracts.ContractGuid, jobRequest.Contracts.ProjectNumber);
                //after updating contract send notification..
                var key = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction(Core.Entities.EnumGlobal.ResourceType.JobRequest.ToString(), "Notify");
                //Core.Entities.EnumGlobal.CrudType.Create.ToString());
                var redirectUrl = string.Format($@"/JobRequest/Detail/{jobRequest.Contracts.ContractGuid}");

                var parameter = new
                {
                    redirectUrl         = redirectUrl,
                    key                 = key,
                    cameFrom            = "Contract Management",
                    resourceName        = "Job Request",
                    resourceDisplayName = "Job Request",
                    resourceId          = jobRequest.Contracts.ContractGuid
                };
                return(RedirectToAction("Index", "Notification", parameter));
                //SendEmailToRespectivePersonnel(jobRequest.Status, jobRequest.Contracts.ContractGuid);
                //return RedirectToAction("Details", jobRequestViewModel.BaseUrl, new { id = jobRequest.Contracts.ContractGuid });
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(jobRequestViewModel));
            }
        }
        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));
            }
        }
示例#21
0
        public ActionResult Edit(JobRequestViewModel jobRequestViewModel)
        {
            try
            {
                List <string> selectionOfCompanies = new List <string>();
                JobRequest    jobRequest           = new JobRequest();
                jobRequest           = ContractsMapper.MapViewModelToJobRequest(jobRequestViewModel);
                jobRequest.UpdatedOn = DateTime.Now;
                jobRequest.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                jobRequest.IsActive  = true;
                jobRequest.IsDeleted = false;
                if (jobRequestViewModel.CompanySelected != null && jobRequestViewModel.CompanySelected.Count > 0)
                {
                    foreach (var name in jobRequestViewModel.CompanySelected)
                    {
                        selectionOfCompanies.Add(name);
                    }
                    jobRequest.Companies = string.Join(",", selectionOfCompanies);
                }
                var loggedUser = UserHelper.GetLoggedUser(HttpContext);

                _jobRequestService.Edit(jobRequest);
                var getPreviousStatus = _jobRequestService.GetCurrentStatusByGuid(jobRequestViewModel.JobRequestGuid);
                if (getPreviousStatus > jobRequestViewModel.Status)
                {
                    SendNotification(jobRequestViewModel.JobRequestGuid, jobRequestViewModel.ContractGuid, jobRequestViewModel.Status);
                }

                //audit log..
                var contractEntity           = _contractRefactorService.GetContractEntityByContractId(jobRequest.ContractGuid);
                var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Edited.ToString(), ResourceType.JobRequest.ToString());
                var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/jobRequest/Detail/" + jobRequestViewModel.ContractGuid);
                var resource = string.Format("{0} </br> Project No :{1} Title:{2}", "Job Request", contractEntity.ProjectNumber, contractEntity.ContractTitle);

                AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), jobRequest.BasicContractInfo, resource, jobRequest.JobRequestGuid, UserHelper.GetHostedIp(HttpContext), "Job Request Edited", Guid.Empty, "Successful", "", additionalInformationURl, additionalInformationURl);
                //end of log..

                //remove president and regional manager from the list
                if (jobRequest.Contracts.ContractUserRole != null)
                {
                    var president = jobRequest.Contracts.ContractUserRole.Where(x => x.UserRole == Contracts._companyPresident).FirstOrDefault();
                    var regional  = jobRequest.Contracts.ContractUserRole.Where(x => x.UserRole == Contracts._regionalManager).FirstOrDefault();
                    jobRequest.Contracts.ContractUserRole.ForEach(x => x.ContractGuid = jobRequest.Contracts.ContractGuid);
                    jobRequest.Contracts.ContractUserRole.Remove(president);
                    jobRequest.Contracts.ContractUserRole.Remove(regional);
                    _contractRefactorService.UpdateContractUsers(jobRequest.Contracts.ContractUserRole);
                }
                _contractRefactorService.UpdateProjectNumberByGuid(jobRequest.Contracts.ContractGuid, jobRequest.Contracts.ProjectNumber);

                var key = Infrastructure.Helpers.FormatHelper.ConcatResourceTypeAndAction(Core.Entities.EnumGlobal.ResourceType.JobRequest.ToString(), "Notify");
                //Core.Entities.EnumGlobal.CrudType.Edit.ToString());
                var redirectUrl = string.Format($@"/JobRequest/Detail/{jobRequest.Contracts.ContractGuid}");
                var parameter   = new
                {
                    redirectUrl         = redirectUrl,
                    key                 = key,
                    cameFrom            = "Contract Management",
                    resourceName        = "JobRequest",
                    resourceDisplayName = "JobRequest",
                    resourceId          = jobRequest.Contracts.ContractGuid
                };
                return(RedirectToAction("Index", "Notification", parameter));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(jobRequestViewModel));
            }
        }
        private void AuditLogForUploadDownload(ContractResourceFile file, string type)
        {
            var    keys = file.Keys;
            string additionalInformation    = string.Empty;
            string additionalInformationURl = string.Empty;
            string resource = string.Empty;

            if (keys.Equals(ResourceType.Contract.ToString()))
            {
                var contractEntity = _contractsService.GetContractEntityByContractId(file.ResourceGuid);
                additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, ResourceType.Contract.ToString().ToLower() + " File");
                additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Contract/Details/" + contractEntity.ContractGuid);
                resource = string.Format("{0} </br>  Contract No:{1} </br> Project No:{2} </br> Contract Title:{3} </br> File Name:{4}", ResourceType.Contract.ToString(), contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
            }
            else if (keys.Equals(ResourceType.TaskOrder.ToString()))
            {
                var contractEntity = _contractsService.GetContractEntityByContractId(file.ResourceGuid);
                additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, ResourceType.TaskOrder.ToString().ToLower() + " File");
                additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractEntity.ContractGuid);
                resource = string.Format("{0} </br>  TaskOrder No:{1} </br> Project No:{2} </br> TaskOrder Title:{3} </br> File Name:{4}", ResourceType.Contract.ToString(), contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
            }
            else if (keys.Equals(ResourceType.ContractModification.ToString()))
            {
                var contractModificationEntity = _contractModificationService.GetDetailById(file.ContentResourceGuid);
                additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, "Contract Mod File");
                additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Contract/Details/" + contractModificationEntity.ContractGuid);
                resource = string.Format("{0} </br> Mod No: {1} </br> Mod Title:{2}</br> File Name:{3}", "Contract Mod", contractModificationEntity.ModificationNumber, contractModificationEntity.ModificationTitle, file.UploadFileName);
            }
            else if (keys.Equals(ResourceType.TaskOrderModification.ToString()))
            {
                var contractModificationEntity = _contractModificationService.GetDetailById(file.ContentResourceGuid);
                additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, "TaskOrder Mod File");
                additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractModificationEntity.ContractGuid);
                resource = string.Format("{0} </br>  Mod No: {1} </br> Mod Title:{2}</br> File Name:{3}", "Contract Mod", contractModificationEntity.ModificationNumber, contractModificationEntity.ModificationTitle, file.UploadFileName);
            }
            else if (keys.Equals(ResourceType.EmployeeBillingRates.ToString()))
            {
                var contractEntity = _contractsService.GetContractEntityByContractId(file.ResourceGuid);
                additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, "Employee Billing Rates File");

                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> Contract Title:{3} </br> File Name:{4}", "Employee Billing Rates", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
                else
                {
                    additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractEntity.ContractGuid);
                    resource = string.Format("{0} </br>  TaskOrder No:{1} </br> Project No:{2} </br> TaskOrder Title:{3} </br> File Name:{4}", "Employee Billing Rates", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
            }
            else if (keys.Equals(ResourceType.WorkBreakDownStructure.ToString()))
            {
                var contractEntity = _contractsService.GetContractEntityByContractId(file.ResourceGuid);
                additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, "Work BreakDown Structure File");

                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> Contract Title:{3} </br> File Name:{4}", "Work BreakDown Structure", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
                else
                {
                    additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractEntity.ContractGuid);
                    resource = string.Format("{0} </br>  TaskOrder No:{1} </br> Project No:{2} </br> TaskOrder Title:{3} </br> File Name:{4}", "Work BreakDown Structure", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
            }
            else if (keys.Equals(ResourceType.LaborCategoryRates.ToString()))
            {
                var contractEntity = _contractsService.GetContractEntityByContractId(file.ResourceGuid);
                additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, "Labor Category Rates File");

                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> Contract Title:{3} </br> File Name:{4}", "Labor Category Rates", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
                else
                {
                    additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractEntity.ContractGuid);
                    resource = string.Format("{0} </br>  TaskOrder No:{1} </br> Project No:{2} </br> TaskOrder Title:{3} </br> File Name:{4}", "Labor Category Rates", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
            }

            AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), file, resource, file.ContractResourceFileGuid, UserHelper.GetHostedIp(HttpContext), "File " + type, Guid.Empty, "Successful", "", additionalInformation, additionalInformationURl);
        }
        public IActionResult Add([FromBody] FarClauseViewModel farClauseViewModel)
        {
            try
            {
                var farClauseEntity = Models.ObjectMapper <FarClauseViewModel, Core.Entities.FarClause> .Map(farClauseViewModel);

                ///Checking duplicate far clause number is not applicable because there might have multiple same number with alternative titles..
                //if (_farClauseService.CheckDuplicateFarClauseNumber(farClauseEntity) > 0)
                //{
                //    var errorMessage = "Duplicate value entered for far clause number !!";
                //    ModelState.AddModelError("", errorMessage);
                //    return BadRequest(ModelState);
                //}

                if (ModelState.IsValid)
                {
                    farClauseEntity.FarClauseGuid = UserHelper.GetNewGuid();
                    farClauseEntity.UpdatedBy     = UserHelper.CurrentUserGuid(HttpContext);
                    farClauseEntity.IsDeleted     = false;
                    _farClauseService.Add(farClauseEntity);

                    //now get body stream.. to save in FarContractTypeCaluse table..
                    Stream req = Request.Body;
                    req.Seek(0, SeekOrigin.Begin);
                    string json = new StreamReader(req).ReadToEnd();

                    var dictValues = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);

                    foreach (KeyValuePair <string, object> entry in dictValues)
                    {
                        var farContractType = _farContractTypeService.GetByCode(entry.Key);

                        if (farContractType != null)
                        {
                            FarContractTypeClause farContractTypeCaluseEntity = new FarContractTypeClause();

                            farContractTypeCaluseEntity.FarClauseGuid       = farClauseEntity.FarClauseGuid;
                            farContractTypeCaluseEntity.FarContractTypeGuid = farContractType.FarContractTypeGuid;

                            farContractTypeCaluseEntity.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                            farContractTypeCaluseEntity.IsDeleted = false;

                            farContractTypeCaluseEntity.IsRequired   = false;
                            farContractTypeCaluseEntity.IsApplicable = false;
                            farContractTypeCaluseEntity.IsOptional   = false;

                            if (entry.Value.Equals("Required"))
                            {
                                farContractTypeCaluseEntity.IsRequired = true;
                            }
                            else if (entry.Value.Equals("Applicable"))
                            {
                                farContractTypeCaluseEntity.IsApplicable = true;
                            }
                            else if (entry.Value.Equals("Optional"))
                            {
                                farContractTypeCaluseEntity.IsOptional = true;
                            }
                            _farContractTypeClauseService.Add(farContractTypeCaluseEntity);
                        }
                        //edit here
                    }

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

                    string[] resourceTitles = { "ResourceTitle", "GUID", "Number", "Title" };
                    string[] resourceValues = { "Far Clause", farClauseEntity.FarClauseGuid.ToString(), farClauseEntity.Number, farClauseEntity.Title };
                    var      resource       = Infrastructure.Helpers.FormatHelper.AuditLogResourceFormat(resourceTitles, resourceValues);

                    AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), farClauseEntity, resource, farClauseEntity.FarClauseGuid, UserHelper.GetHostedIp(HttpContext), "Far Clause Added", Guid.Empty, "Successful", "", additionalInformation, additionalInformationURl);
                    //end of log..

                    return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!" }));
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }
示例#24
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));
            }
        }
        public IActionResult Edit([FromBody] FarClauseViewModel farClauseViewModel)
        {
            try
            {
                var farClauseEntity = Models.ObjectMapper <FarClauseViewModel, Core.Entities.FarClause> .Map(farClauseViewModel);

                if (ModelState.IsValid)
                {
                    if (!ModelState.IsValid)
                    {
                        return(BadRequest(ModelState));
                    }
                    farClauseEntity.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);

                    //update the farclause..
                    _farClauseService.Edit(farClauseEntity);

                    //now get body stream.. to edit FarContractTypeCaluse table....
                    Stream req = Request.Body;
                    req.Seek(0, SeekOrigin.Begin);
                    string json = new StreamReader(req).ReadToEnd();

                    var dictValues = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);

                    foreach (KeyValuePair <string, object> entry in dictValues)
                    {
                        var farContractType = _farContractTypeService.GetByCode(entry.Key);
                        if (farContractType != null)
                        {
                            var farContractTypeCaluse = _farContractTypeClauseService.GetByFarClauseFarContractTypeGuid(farClauseViewModel.FarClauseGuid, farContractType.FarContractTypeGuid);

                            if (farContractTypeCaluse == null)
                            {
                                //add if there is no farcontracttypeclause record..
                                FarContractTypeClause farContractTypeCaluseEntity = new FarContractTypeClause
                                {
                                    FarClauseGuid       = farClauseEntity.FarClauseGuid,
                                    FarContractTypeGuid = farContractType.FarContractTypeGuid,
                                    UpdatedBy           = UserHelper.CurrentUserGuid(HttpContext),
                                    IsDeleted           = false,
                                    IsRequired          = false,
                                    IsApplicable        = false,
                                    IsOptional          = false
                                };

                                if (entry.Value.Equals("Required"))
                                {
                                    farContractTypeCaluseEntity.IsRequired = true;
                                }
                                else if (entry.Value.Equals("Applicable"))
                                {
                                    farContractTypeCaluseEntity.IsApplicable = true;
                                }
                                else if (entry.Value.Equals("Optional"))
                                {
                                    farContractTypeCaluseEntity.IsOptional = true;
                                }
                                _farContractTypeClauseService.Add(farContractTypeCaluseEntity);
                                continue;
                            }
                            farContractTypeCaluse.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                            farContractTypeCaluse.IsDeleted = false;

                            farContractTypeCaluse.IsRequired   = false;
                            farContractTypeCaluse.IsApplicable = false;
                            farContractTypeCaluse.IsOptional   = false;

                            if (entry.Value.Equals("Required"))
                            {
                                farContractTypeCaluse.IsRequired = true;
                            }
                            else if (entry.Value.Equals("Applicable"))
                            {
                                farContractTypeCaluse.IsApplicable = true;
                            }
                            else if (entry.Value.Equals("Optional"))
                            {
                                farContractTypeCaluse.IsOptional = true;
                            }
                            _farContractTypeClauseService.Edit(farContractTypeCaluse);
                        }
                        //edit here
                    }

                    //audit log..
                    var additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, CrudTypeForAdditionalLogMessage.Edited.ToString(), "Far Clause");
                    var additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Admin/FarClause");

                    string[] resourceTitles = { "ResourceTitle", "GUID", "Number", "Title" };
                    string[] resourceValues = { "Far Clause", farClauseEntity.FarClauseGuid.ToString(), farClauseEntity.Number, farClauseEntity.Title };
                    var      resource       = FormatHelper.AuditLogResourceFormat(resourceTitles, resourceValues);

                    AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), farClauseEntity, resource, farClauseEntity.FarClauseGuid, UserHelper.GetHostedIp(HttpContext), "Far Clause Edited", Guid.Empty, "Successful", "", additionalInformation, additionalInformationURl);
                    //end of log..

                    return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Updated !!" }));
                }
                else
                {
                    return(View(farClauseEntity));
                }
            }
            catch (ArgumentException ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequestFormatter.BadRequest(this, ex));;
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(BadRequestFormatter.BadRequest(this, e));
            }
        }