Пример #1
0
        public bool AddUpdateLoanCustomerFSCaptionDetail(LoanCustomerFSCaptionDetailObj entity)
        {
            try
            {
                if (entity == null)
                {
                    return(false);
                }

                credit_loancustomerfscaptiondetail fsCaptionDetail = null;
                if (entity.FSDetailId > 0)
                {
                    fsCaptionDetail = _dataContext.credit_loancustomerfscaptiondetail.Find(entity.FSDetailId);
                    if (fsCaptionDetail != null)
                    {
                        fsCaptionDetail.FSCaptionId = entity.FSCaptionId;
                        fsCaptionDetail.FSDate      = entity.FSDate;
                        fsCaptionDetail.Amount      = entity.Amount;
                        fsCaptionDetail.CustomerId  = entity.CustomerId;
                        fsCaptionDetail.Active      = true;
                        fsCaptionDetail.Deleted     = false;
                        fsCaptionDetail.UpdatedBy   = entity.CreatedBy;
                        fsCaptionDetail.UpdatedOn   = DateTime.Now;
                    }
                }
                else
                {
                    fsCaptionDetail = new credit_loancustomerfscaptiondetail
                    {
                        FSCaptionId = entity.FSCaptionId,
                        FSDate      = entity.FSDate,
                        Amount      = entity.Amount,
                        CustomerId  = entity.CustomerId,
                        Active      = true,
                        Deleted     = false,
                        CreatedBy   = entity.CreatedBy,
                        CreatedOn   = DateTime.Now,
                    };
                    _dataContext.credit_loancustomerfscaptiondetail.Add(fsCaptionDetail);
                }

                var response = _dataContext.SaveChanges() > 0;

                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #2
0
        public async Task <ActionResult <LoanCustomerFSCaptionGroupRespObj> > AddUpdateLoanCustomerFSCaptionDetail([FromBody] LoanCustomerFSCaptionDetailObj model)
        {
            try
            {
                var identity = await _identityServer.UserDataAsync();

                var user = identity.UserName;

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

                var response = _repo.AddUpdateLoanCustomerFSCaptionDetail(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
                        }
                    }
                });
            }
        }