Esempio n. 1
0
        public bool AddUpdateLoanCustomerFSRatioDetail(LoanCustomerFSRatioDetailObj entity)
        {
            try
            {
                if (entity == null)
                {
                    return(false);
                }

                credit_loancustomerratiodetail ratioDetail = null;

                if (!ValidateDescriptionRatio(entity.Description))
                {
                    return(false);
                }
                ;

                ratioDetail = _dataContext.credit_loancustomerratiodetail.FirstOrDefault(x => x.RatioName.ToLower().TrimStart() == entity.RatioName.ToLower().TrimStart());
                if (ratioDetail != null)
                {
                    ratioDetail.Description   = entity.Description;
                    ratioDetail.RatioDetailId = entity.RatioDetailId;
                    ratioDetail.RatioName     = entity.RatioName;
                    ratioDetail.Active        = true;
                    ratioDetail.Deleted       = false;
                    ratioDetail.UpdatedBy     = entity.CreatedBy;
                    ratioDetail.UpdatedOn     = DateTime.Now;
                }
                else
                {
                    ratioDetail = new credit_loancustomerratiodetail
                    {
                        Description   = entity.Description,
                        RatioDetailId = entity.RatioDetailId,
                        RatioName     = entity.RatioName,
                        Active        = true,
                        Deleted       = false,
                        CreatedBy     = entity.CreatedBy,
                        CreatedOn     = DateTime.Now,
                    };
                    _dataContext.credit_loancustomerratiodetail.Add(ratioDetail);
                }

                var response = _dataContext.SaveChanges() > 0;

                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 2
0
        public async Task <ActionResult <LoanCustomerFSCaptionGroupRespObj> > AddUpdateLoanCustomerFSRatioDetail([FromBody] LoanCustomerFSRatioDetailObj model)
        {
            try
            {
                var identity = await _identityServer.UserDataAsync();

                var user = identity.UserName;

                model.CreatedBy = user;
                model.UpdatedBy = user;

                var response = _repo.AddUpdateLoanCustomerFSRatioDetail(model);
                if (response)
                {
                    return(new LoanCustomerFSCaptionGroupRespObj
                    {
                        Status = new APIResponseStatus {
                            IsSuccessful = true, Message = new APIResponseMessage {
                                FriendlyMessage = $"Record saved successfully."
                            }
                        }
                    });
                }
                return(new LoanCustomerFSCaptionGroupRespObj
                {
                    Status = new APIResponseStatus {
                        IsSuccessful = false, Message = new APIResponseMessage {
                            FriendlyMessage = "Record not saved"
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                var errorCode = ErrorID.Generate(5);
                _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                return(new LoanCustomerFSCaptionGroupRespObj
                {
                    Status = new APIResponseStatus {
                        IsSuccessful = false, Message = new APIResponseMessage {
                            FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode
                        }
                    }
                });
            }
        }