예제 #1
0
        public async Task <bool> AddUpdateTransferSetupAsync(deposit_transfersetup model)
        {
            try
            {
                if (model.TransferSetupId > 0)
                {
                    var itemToUpdate = await _dataContext.deposit_transfersetup.FindAsync(model.TransferSetupId);

                    _dataContext.Entry(itemToUpdate).CurrentValues.SetValues(model);
                }
                else
                {
                    await _dataContext.deposit_transfersetup.AddAsync(model);
                }
                return(await _dataContext.SaveChangesAsync() > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public async Task <bool> UploadTransferSetupAsync(List <byte[]> record, string createdBy)
        {
            try
            {
                if (record == null)
                {
                    return(false);
                }
                ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
                List <deposit_transfersetup> uploadedRecord = new List <deposit_transfersetup>();
                if (record.Count() > 0)
                {
                    foreach (var byteItem in record)
                    {
                        using (MemoryStream stream = new MemoryStream(byteItem))
                            using (ExcelPackage excelPackage = new ExcelPackage(stream))
                            {
                                ExcelWorksheet workSheet = excelPackage.Workbook.Worksheets[0];
                                int            totalRows = workSheet.Dimension.Rows;

                                for (int i = 2; i <= totalRows; i++)
                                {
                                    var item = new deposit_transfersetup
                                    {
                                        //can = workSheet.Cells[i, 1].Value.ToString(),
                                        //CanApply = workSheet.Cells[i, 2].Value.ToString()
                                    };
                                    uploadedRecord.Add(item);
                                }
                            }
                    }
                }
                if (uploadedRecord.Count > 0)
                {
                    foreach (var item in uploadedRecord)
                    {
                        var Transferexist = _dataContext.deposit_transfersetup.Where(x => x.TransferSetupId == item.TransferSetupId && x.Deleted == false).FirstOrDefault();
                        if (Transferexist != null)
                        {
                            Transferexist.Product = item.Product;
                            //Transferexist.can = item.CanApply;
                            Transferexist.Active    = true;
                            Transferexist.Deleted   = false;
                            Transferexist.UpdatedBy = item.UpdatedBy;
                            Transferexist.UpdatedOn = DateTime.Now;
                        }

                        else
                        {
                            var Transfer = new deposit_transfersetup
                            {
                                Product = item.Product,
                                //Description = item.Description,
                                Active    = true,
                                Deleted   = false,
                                CreatedBy = createdBy,
                                CreatedOn = DateTime.Now,
                            };
                            await _dataContext.deposit_transfersetup.AddAsync(Transfer);
                        }
                    }
                }

                var response = _dataContext.SaveChanges() > 0;
                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #3
0
        public async Task <ActionResult <TransferSetupRegRespObj> > AddUpdateTransferSetupAsync([FromBody] AddUpdateTransferSetupObj model)
        {
            try
            {
                var user = await _identityServer.UserDataAsync();

                deposit_transfersetup item = null;
                if (model.TransferSetupId > 0)
                {
                    item = await _repo.GetTransferSetupByIdAsync(model.TransferSetupId);

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

                var domainObj = new deposit_transfersetup();

                domainObj.TransferSetupId      = model.TransferSetupId > 0 ? model.TransferSetupId : 0;
                domainObj.Structure            = model.Structure;
                domainObj.PresetChart          = model.PresetChart;
                domainObj.AccountType          = model.AccountType;
                domainObj.DailyWithdrawalLimit = model.DailyWithdrawalLimit;
                domainObj.ChargesApplicable    = model.ChargesApplicable;
                domainObj.Charges    = model.Charges;
                domainObj.ChargeType = model.ChargeType;
                domainObj.Active     = true;
                domainObj.CreatedOn  = DateTime.Today;
                domainObj.CreatedBy  = user.UserName;
                domainObj.Deleted    = false;
                domainObj.UpdatedOn  = model.TransferSetupId > 0 ? DateTime.Today : DateTime.Today;
                domainObj.UpdatedBy  = user.UserName;

                var isDone = await _repo.AddUpdateTransferSetupAsync(domainObj);

                return(new TransferSetupRegRespObj
                {
                    TransferSetupId = domainObj.TransferSetupId,
                    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 TransferSetupRegRespObj
                {
                    Status = new APIResponseStatus {
                        IsSuccessful = false, Message = new APIResponseMessage {
                            FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode
                        }
                    }
                });
            }
        }