private async Task <bool> ValidateUpdateModel(int _staffid, int _borrowerid, SalesBorrower _model)
        {
            var _staff = await unitOfWorks.Staffs().GetSingleByStaffId(_staffid);

            if (_staff == null)
            {
                ModelState.AddModelError("staffid", "Staff not found.");
            }

            return(ModelState.IsValid);
        }
        public async Task <IActionResult> Create([FromBody] SalesBorrower model)
        {
            if (model == null)
            {
                httpResult = new FSResponseMessage(FSStatusCode.BadRequest, FSStatusMessage.fail, HttpResponseMessageKey.ArgsNull);
                goto response;
            }

            if (!await ValidateCreateModel(model))
            {
                var _modelState = ModelState
                                  .Where(x => x.Value.ValidationState == ModelValidationState.Invalid)
                                  .ToDictionary(x => x.Key, x => x.Value.Errors[0].ErrorMessage);

                httpResult = new FSResponseData <Dictionary <string, string> >(FSStatusCode.UnprocessableEntity, FSStatusMessage.fail, _modelState);
                goto response;
            }

            try
            {
                model.Init();
                unitOfWorks.SalesBorrowers().Add(model);

                int _status = await unitOfWorks.Save();

                if (_status == 1)
                {
                    httpResult = new FSResponseMessage(FSStatusCode.OK, FSStatusMessage.success, HttpResponseMessageKey.DataSuccessfullyCreated);
                }
                else
                {
                    httpResult = new FSResponseMessage(FSStatusCode.InternalServerErrorException, FSStatusMessage.error, HttpResponseMessageKey.DataUnsuccessfullyCreated);
                }
            }
            catch (Exception ex)
            {
                httpResult = new FSResponseMessage(FSStatusCode.InternalServerErrorException, FSStatusMessage.error, ex.Message);
            }

response:
            return(FSHttpResponse(httpResult));
        }
 private async Task <bool> IsValidToDeleteModel(SalesBorrower _model)
 {
     return(true);
 }
 private async Task <bool> ValidateCreateModel(SalesBorrower _model)
 {
     return(ModelState.IsValid);
 }