Ejemplo n.º 1
0
        public IHttpActionResult ObtainCredit(CreditDto creditDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Provided data is incorrect"));
            }

            var userId = User.Identity.GetUserId().Value;

            creditDto.UserId = userId;

            var result = _creditService.CreateCredit(creditDto);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }
            else
            {
                return(Ok(result.Message));
            }
        }
Ejemplo n.º 2
0
 public ActionResult CreateCredit(CreditViewModel model)
 {
     if (ModelState.IsValid)
     {
         decimal needAllocateAmount;
         var     userId = User.Identity.GetUserId();
         if (creditService.EnbleToCreateCredit(model, userId, out needAllocateAmount))
         {
             model.UserId = userId;
             creditService.CreateCredit(model);
             creditService.AllocationCredit(model, model.UserId);
             TempData["CreditCreated"] = true;
             return(RedirectToAction("CreateCredit", "Home"));
         }
         else
         {
             ViewBag.CreditCreated      = false;
             ViewBag.NeedAllocateAmount = needAllocateAmount;
             return(View("CreateCredit", model));
         }
     }
     return(View("CreateCredit", model));
 }