Ejemplo n.º 1
0
        public async Task <ActionResult <FeeRegRespObj> > GetFeeByIdAsync([FromBody] AddUpdateFeeObj model)
        {
            try
            {
                credit_fee item = null;
                if (model.FeeId > 0)
                {
                    item = await _repo.GetFeeByIdAsync(model.FeeId);

                    if (item == null)
                    {
                        return new FeeRegRespObj
                               {
                                   Status = new APIResponseStatus {
                                       IsSuccessful = false, Message = new APIResponseMessage {
                                           FriendlyMessage = "Item does not Exist"
                                       }
                                   }
                               }
                    }
                    ;
                }

                var domainObj = new credit_fee();
                domainObj.FeeId      = model.FeeId > 0 ? model.FeeId : 0;
                domainObj.FeeName    = model.FeeName;
                domainObj.IsIntegral = model.IsIntegral;
                domainObj.TotalFeeGL = model.TotalFeeGL;
                domainObj.Active     = true;
                domainObj.CreatedBy  = string.Empty;
                domainObj.CreatedOn  = DateTime.Today;
                domainObj.Deleted    = false;
                domainObj.UpdatedBy  = string.Empty;
                domainObj.UpdatedOn  = model.FeeId > 0 ? DateTime.Today : DateTime.Today;

                var isDone = await _repo.AddUpdateFeeAsync(domainObj);

                return(new FeeRegRespObj
                {
                    FeeId = domainObj.FeeId,
                    Status = new APIResponseStatus {
                        IsSuccessful = isDone ? true : false, Message = new APIResponseMessage {
                            FriendlyMessage = isDone ? "successful" : "Unsuccessful"
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                var errorCode = ErrorID.Generate(5);
                _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                return(new FeeRegRespObj
                {
                    Status = new APIResponseStatus {
                        IsSuccessful = false, Message = new APIResponseMessage {
                            FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode
                        }
                    }
                });
            }
        }