public async Task <IHttpActionResult> Post(PaymentMethod item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            item.ObjectState = ObjectState.Added;
            _service.Insert(item);

            try
            {
                await _unitOfWorkAsync.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ItemExists(item.PaymentMethodID))
                {
                    return(Conflict());
                }
                throw;
            }

            return(Created(item));
        }
Beispiel #2
0
 public HttpResponseMessage Post(PaymentMethod paymentMethod)
 {
     if (ModelState.IsValid)
     {
         service.Insert(paymentMethod);
         return(new HttpResponseMessage(HttpStatusCode.OK));
     }
     else
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
 }
        public ActionResult Create(PaymentMethodDto viewModel)
        {
            if (ModelState.IsValid)
            {
                _paymentMethodService.Insert(viewModel);

                {
                    return(RedirectToAction("List"));
                }
            }
            return(View(viewModel));
        }
Beispiel #4
0
        public ActionResult Add(string description)
        {
            try
            {
                var paymentMethod = new PaymentMethod();

                paymentMethod.Description = description;
                paymentMethod.Status      = 1;

                _paymentMethodService.Insert(paymentMethod);
                _paymentMethodService.SaveChanges();

                return(Content("1"));
            }
            catch (Exception)
            {
                return(Content("0"));
            }
        }