public IActionResult Edit([FromBody] FarContractTypeClause data)
        {
            try
            {
                var entity = _farContractTypeClauseService.GetById(data.FarContractTypeClauseGuid);
                entity.IsApplicable = data.IsApplicable;
                entity.IsRequired   = data.IsRequired;
                entity.IsOptional   = data.IsOptional;
                entity.UpdatedBy    = UserHelper.CurrentUserGuid(HttpContext);

                _farContractTypeClauseService.Edit(entity);

                return(Json(new { status = true }));
            }
            catch (Exception ex)
            {
                ModelState.Clear();
                ModelState.AddModelError("", ex.Message);
                return(BadRequestFormatter.BadRequest(this, ex));
            }
        }
        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));
            }
        }