Пример #1
0
 public IHttpActionResult Post([FromBody] Type item)
 {
     if (item != null)
     {
         service.Create(item);
         return(CreatedAtRoute("DefaultApi", new { id = item.ID }, item));
     }
     return(BadRequest());
 }
Пример #2
0
        public ActionResult Create([Bind(Include = "ID,Description,Status")] Core.Type type)
        {
            if (ModelState.IsValid)
            {
                typeService.Create(type);
                return(RedirectToAction("Index"));
            }

            return(View(type));
        }
Пример #3
0
        public async Task <ActionResult <Type> > Post(
            [FromBody] CreateType type,
            CancellationToken cancellationToken)
        {
            var tenantId = "GET FROM JWT";

            return(await _typeService.Create(
                       type,
                       tenantId,
                       cancellationToken));
        }
Пример #4
0
 public ActionResult Post([FromBody] Type type)
 {
     try
     {
         var status = typesService.Create(type);
         return(Ok(status));
     }
     catch (System.Exception ex)
     {
         Logger.LogError(ex, "Type: {Type}. Message: {Message}", ex.GetType(), ex.Message);
         return(BadRequest($"{ex.GetType()}: {ex.Message}"));
     }
 }
Пример #5
0
        public ActionResult Create(CreateTypeViewModel viewModel)
        {
            var request  = viewModel.MapTo <CreateTypeRequest>();
            var response = _typeService.Create(request);

            TempData["IsSuccess"] = response.IsSuccess;
            TempData["Message"]   = response.Message;
            if (response.IsSuccess)
            {
                return(RedirectToAction("Index"));
            }

            return(View("Create", viewModel));
        }
Пример #6
0
 public IActionResult Post([FromBody] TypeDto value)
 {
     try
     {
         return(Ok(service.Create(value)));
     }
     catch (ValidationException e)
     {
         return(BadRequest(e.Message));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
Пример #7
0
        public void Create()
        {
            //Arrange
            Type item = new Type
            {
                Description = "test",
                Status      = "test"
            };

            unitWorkMock.Setup(x => x.Type.Create(item)).Callback(() => {
                item.ID = id;
            });

            //Act
            serviceMock.Create(item);

            //Assert
            Assert.AreEqual(id, item.ID);
        }
 public ActionResult Create(TypeViewModel model)
 {
     if (string.IsNullOrEmpty(model.Description))
     {
         ModelState.AddModelError("Description", "Описание должно быть заполнено");
     }
     if (string.IsNullOrEmpty(model.Status))
     {
         ModelState.AddModelError("Status", "Статус должен быть заполнен");
     }
     if (ModelState.IsValid)
     {
         service.Create(new Type {
             Description = model.Description,
             Status      = model.Status
         });
         return(RedirectToAction("Index", "Type"));
     }
     return(View(model));
 }
Пример #9
0
 public IHttpActionResult Create(string description, int userId)
 {
     return(Ok(_typeService.Create(description, userId)));
 }