/// <summary>
        /// Delete an entity.
        /// </summary>
        /// <param name="model"></param>
        public void Delete(PaymentMethodViewModel model)
        {
            var entity = model.ToEntity();

            this._PaymentMethodsRepository.Delete(entity);

            #region Commit Changes
            this._unitOfWork.Commit();
            #endregion
        }
        /// <summary>
        /// Update an entity.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public PaymentMethodViewModel Update(PaymentMethodViewModel model)
        {
            this.ThrowExceptionIfExist(model);

            var entity = model.ToEntity();

            entity = this._PaymentMethodsRepository.Update(entity);

            #region Commit Changes
            this._unitOfWork.Commit();
            #endregion

            model = entity.ToModel();
            return(model);
        }
Exemple #3
0
        public async Task <IActionResult> Create(PaymentMethodViewModel model)
        {
            if (!HasPermission("CREATE_PAYMENT_METHODS"))
            {
                return(Unauthorized());
            }

            if (ModelState.IsValid)
            {
                var paymentMethod = model.ToEntity();

                _context.PaymentMethods.Add(paymentMethod);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }