Esempio n. 1
0
        public async Task <IResponse <StoreDTO> > FindAsDtoAsync(int id)
        {
            try
            {
                var store = await _storeRepo.FindAsync(id);

                if (store == null)
                {
                    return new Response <StoreDTO>
                           {
                               IsSuccessful = false,
                               Message      = ServiceMessage.RecordNotExist
                           }
                }
                ;

                return(new Response <StoreDTO>
                {
                    IsSuccessful = true,
                    Result = new StoreDTO
                    {
                        Name = store.FullName,
                        LogoUrl = store.ProfilePictureUrl
                    }
                });
            }
            catch (Exception e)
            {
                return(new Response <StoreDTO> {
                });
            }
        }
Esempio n. 2
0
        public async Task <IResponse <string> > Verify(Payment payment, object[] args)
        {
            var findGateway = await _gatewayFactory.GetInsance(payment.PaymentGatewayId);

            if (!findGateway.IsSuccessful)
            {
                return new Response <string> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;
            var verify = await findGateway.Result.Service.VerifyTransaction(new VerifyRequest
            {
                OrderId       = payment.OrderId,
                TransactionId = payment.TransactionId,
                ApiKey        = findGateway.Result.Gateway.MerchantId,
                Url           = findGateway.Result.Gateway.VerifyUrl
            }, args);

            if (!verify.IsSuccessful)
            {
                return new Response <string> {
                           IsSuccessful = false, Result = payment.TransactionId
                }
            }
            ;
            var order = await _orderRepo.FindAsync(payment.OrderId);

            if (order == null)
            {
                return new Response <string> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;
            order.OrderStatus     = OrderStatus.InProcessing;
            payment.PaymentStatus = PaymentStatus.Success;
            _appUow.OrderRepo.Update(order);
            _appUow.PaymentRepo.Update(payment);
            var update = await _appUow.ElkSaveChangesAsync();

            return(new Response <string>
            {
                IsSuccessful = update.IsSuccessful,
                Result = payment.TransactionId,
                Message = update.Message
            });
        }
        public async Task <IResponse <string> > DeleteAsync(int id)
        {
            try
            {
                var asset = await _lossAssetRepo.FindAsync(id);

                if (asset == null)
                {
                    return new Response <string> {
                               Message = ServiceMessage.RecordNotExist
                    }
                }
                ;
                _lossAssetRepo.Delete(asset);
                var delete = await _appUow.ElkSaveChangesAsync();

                if (File.Exists(asset.PhysicalPath))
                {
                    File.Delete(asset.PhysicalPath);
                }
                return(new Response <string> {
                    IsSuccessful = delete.IsSuccessful, Message = delete.Message
                });
            }
            catch (Exception e)
            {
                FileLoger.Error(e);
                return(new Response <string> {
                    Message = ServiceMessage.Error
                });
            }
        }
        public async Task <IResponse <ProductCategory> > FindAsync(int id)
        {
            var item = await _productCategoryRepo.FindAsync(id);

            if (item == null)
            {
                return new Response <ProductCategory> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;

            return(new Response <ProductCategory> {
                Result = item, IsSuccessful = true
            });
        }
        public async Task <IResponse <BankAccount> > UpdateAsync(BankAccount model)
        {
            var BankAccount = await _BankAccountRepo.FindAsync(model.BankAccountId);

            if (BankAccount == null)
            {
                return new Response <BankAccount> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;

            BankAccount.BankName      = model.BankName;
            BankAccount.Shaba         = model.Shaba;
            BankAccount.AccountNumber = model.AccountNumber;

            var saveResult = _appUow.ElkSaveChangesAsync();

            return(new Response <BankAccount> {
                Result = BankAccount, IsSuccessful = saveResult.Result.IsSuccessful, Message = saveResult.Result.Message
            });
        }
Esempio n. 6
0
        public async Task <IResponse <Address> > FindAsync(int id)
        {
            var addr = await _addressRepo.FindAsync(id);

            if (addr == null)
            {
                return new Response <Address> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;
            else
            {
                return new Response <Address> {
                           IsSuccessful = true, Result = addr
                }
            };
        }
    }
Esempio n. 7
0
        public async Task <IResponse <Relative> > UpdateAsync(Relative model)
        {
            var Relative = await _RelativeRepo.FindAsync(model.RelativeId);

            if (Relative == null)
            {
                return new Response <Relative> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;

            Relative.Name           = model.Name;
            Relative.Family         = model.Family;
            Relative.FatherName     = model.FatherName;
            Relative.Gender         = model.Gender;
            Relative.BirthDay       = model.BirthDay;
            Relative.BirthDayMi     = PersianDateTime.Parse(model.BirthDay).ToDateTime();
            Relative.IdentityNumber = model.IdentityNumber;
            Relative.NationalCode   = model.NationalCode;
            Relative.RelativeType   = model.RelativeType;
            Relative.TakafolKind    = model.TakafolKind;
            _RelativeRepo.Update(Relative);
            #region Save Attachments
            if (model.RelativeAttachmentIds != null && model.RelativeAttachmentIds.Count > 0)
            {
                var attachments = _appUow.RelativeAttachmentRepo.Get(conditions: x => model.RelativeAttachmentIds.Contains(x.RelativeAttachmentId), orderBy: o => o.OrderBy(ClosedXML => ClosedXML.InsertDateMi));

                if (attachments != null)
                {
                    foreach (var attachment in attachments)
                    {
                        attachment.RelativeId = model.RelativeId;
                        _appUow.RelativeAttachmentRepo.Update(attachment);
                    }
                }
            }
            #endregion
            var saveResult = _appUow.ElkSaveChangesAsync();
            return(new Response <Relative> {
                IsSuccessful = saveResult.Result.IsSuccessful, Message = saveResult.Result.Message
            });
        }
Esempio n. 8
0
        public async Task <IResponse <Address> > UpdateAsync(Address model)
        {
            var address = await _addressRepo.FindAsync(model.AddressId);

            if (address == null)
            {
                return new Response <Address> {
                           Message = ServiceMessage.RecordNotExist
                }
            }
            ;

            address.UserId         = model.UserId;
            address.Province       = model.Province;
            address.City           = model.City;
            address.AddressDetails = model.AddressDetails;

            var saveResult = _appUow.ElkSaveChangesAsync();

            return(new Response <Address> {
                Result = address, IsSuccessful = saveResult.Result.IsSuccessful, Message = saveResult.Result.Message
            });
        }