public IHttpActionResult Post([FromBody] Type item) { if (item != null) { service.Create(item); return(CreatedAtRoute("DefaultApi", new { id = item.ID }, item)); } return(BadRequest()); }
public ActionResult Create([Bind(Include = "ID,Description,Status")] Core.Type type) { if (ModelState.IsValid) { typeService.Create(type); return(RedirectToAction("Index")); } return(View(type)); }
public async Task <ActionResult <Type> > Post( [FromBody] CreateType type, CancellationToken cancellationToken) { var tenantId = "GET FROM JWT"; return(await _typeService.Create( type, tenantId, cancellationToken)); }
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}")); } }
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)); }
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)); } }
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)); }
public IHttpActionResult Create(string description, int userId) { return(Ok(_typeService.Create(description, userId))); }