Esempio n. 1
0
        public IActionResult Create([FromBody] PaymentTypeRequest request)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(request.Code))
                {
                    return(BadRequest("Invalid code"));
                }

                if (string.IsNullOrWhiteSpace(request.Description))
                {
                    return(BadRequest("Invalid description"));
                }

                var type = new PaymentType
                {
                    Code        = request.Code,
                    Description = request.Description,
                    CreateDate  = DateTime.Now,
                    UpdateDate  = null,
                    UserId      = UserID
                };

                _repository.Insert(type);

                var response = _mapper.Map <PaymentType, PaymentTypeResponse>(type);
                return(Ok(response));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
 public ActionResult Create(PaymentType paymentType)
 {
     try
     {
         repository.Insert(paymentType);
         return(RedirectToAction("Index", "PaymentTypes"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 3
0
 public int Insert(PaymentType payment_type)
 {
     return(_repository.Insert(payment_type));
 }