Beispiel #1
0
        public BaseViewModel <string> DeletePaymentMethod(Guid id)
        {
            //Find PaymentMethod
            var userId        = new Guid(_repository.GetCurrentUserId());
            var paymentMethod = _repository.GetMany(_ => _.IsDelete == false && _.UserId == userId && _.Id == id).FirstOrDefault();
            //result to return
            BaseViewModel <string> result = null;

            //check PaymentMethod exist
            if (paymentMethod == null)
            {
                result = new BaseViewModel <string>()
                {
                    StatusCode  = HttpStatusCode.NotFound,
                    Code        = ErrMessageConstants.NOTFOUND,
                    Description = MessageHandler.CustomErrMessage(ErrMessageConstants.NOTFOUND)
                };
            }
            else
            {
                //update column isDelete = true
                paymentMethod.IsDelete = true;
                _repository.Update(paymentMethod);
                result = new BaseViewModel <string>();
                //save change
                Save();
            }
            return(result);
        }
Beispiel #2
0
        public bool SetDefaultPaymentMethod(string userId, int paymentMethodId)
        {
            bool isContainPM = false;

            try
            {
                List <PaymentMethods> userPaymentMethods = _paymentMethodRepository.GetAll().Where(pm => pm.UserId == userId).ToList();
                foreach (var upm in userPaymentMethods)
                {
                    if (upm.Id == paymentMethodId)
                    {
                        isContainPM   = true;
                        upm.IsDefault = true;
                    }
                    else
                    {
                        upm.IsDefault = false;
                    }
                    _paymentMethodRepository.Update(upm);
                }
                return(isContainPM);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #3
0
        public async Task <IActionResult> ExecuteAsync(int paymentMethodId, SavePaymentMethod savePaymentMethod, CancellationToken cancellationToken)
        {
            var paymentMethod = await _paymentMethodRepository.Get(paymentMethodId, cancellationToken);

            if (paymentMethod == null)
            {
                return(new NotFoundResult());
            }
            _paymentMethodToSavePaymentMethodMapper.Map(savePaymentMethod, paymentMethod);

            //var user = _httpContextAccessor.HttpContext.User;
            //if (user == null)
            //    return new NotFoundResult();

            //var claims = user.Claims.ToList();
            //if (claims.Count < 1)
            //    return new NotFoundResult();
            //// Lấy Id của người dùng
            //var userId = claims.FirstOrDefault(claimRecord => claimRecord.Type == "sub")?.Value;

            //paymentMethod.ModifiedBy = userId;

            paymentMethod = await _paymentMethodRepository.Update(paymentMethod, cancellationToken);

            var paymentMethodViewModel = _paymentMethodToPaymentMethodMapper.Map(paymentMethod);

            return(new OkObjectResult(paymentMethodViewModel));
        }
Beispiel #4
0
        public bool Update(PaymentMethodViewModel vm, Guid id)
        {
            var paymentMethod = Mapper.Map <PaymentMethod>(vm);

            var result = _paymentMethodRepository.Update(paymentMethod, id);

            return(result != null);
        }
        public ActionResult Update(PaymentMethods model)
        {
            try
            {
                var data = repository.Update(model);

                return(Ok(new { success = true, successMessage = "Updated Successfully!" }));
            }
            catch (Exception ex)
            {
                return(Ok(new { success = false, errorMessage = ex.GetBaseException() }));
            }
        }
Beispiel #6
0
 /// <summary>
 /// Method whose purpose is to update an
 /// existing PaymentMethod record.
 /// </summary>
 /// <param name="paymentMethod">
 /// Existing PaymentMethodModel object.
 /// </param>
 /// <returns>
 /// Returns true if the query is successfully executed
 /// otherwise returns false.
 /// </returns>
 public bool Update(PaymentMethodModel paymentMethod)
 {
     return(_paymentMethodRepository.Update(paymentMethod) > 0 ? true : false);
 }
 public void Update(PaymentMethod entity)
 {
     _PaymentMethodRepository.Update(entity);
 }