示例#1
0
        public ActionResult Detail(Guid id)
        {
            var farContractTypeModel = _farContractTypeService.GetById(id);
            FarContractTypeViewModel farContractTypeViewModel = new FarContractTypeViewModel();

            farContractTypeViewModel = Models.ObjectMapper <FarContractType, FarContractTypeViewModel> .Map(farContractTypeModel);

            return(PartialView(farContractTypeViewModel));
        }
示例#2
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));
            }
        }
示例#3
0
        public ActionResult Add()
        {
            FarContractTypeViewModel FarContractTypeViewModel = new FarContractTypeViewModel();

            return(PartialView(FarContractTypeViewModel));
        }