public HttpResponseMessage Post(ItemViewModel itemVm) { Item item = itemVm.MapToEntity(); var addedItem = _itemsService.Add(item); return(Request.CreateResponse(HttpStatusCode.Created, addedItem)); }
public ActionResult Create(DtoItem item) { ServiceResult <DtoItem> result = _service.Add(item); if (result.Success) { return(Json(result.Item)); } return(new HttpStatusCodeResult(400, result.ErrorMessage)); }
public IActionResult Add(AddItemInputModel inputModel) { if (!ModelState.IsValid) { return(View()); } _itemsService.Add(inputModel); return(Redirect(Items_Root_Path)); }
public override bool SaveEntity() { var itemEntity = new CiItemsEntity { Code = txtCode.Text.Trim(), FullName = txtFullName.Text.Trim(), Category = string.IsNullOrEmpty(cboCategory.SelectedValue.ToString())? null: cboCategory.SelectedValue.ToString(), Description = txtDescription.Text.Trim(), DeleteMark = 0, Enabled = chkEnabled.Checked ? 1 : 0 }; if (base.UserInfo != null) { itemEntity.CreateBy = UserInfo.RealName; itemEntity.CreateUserId = UserInfo.Id; } var statusMessage = string.Empty; var statusCode = string.Empty; try { itemsService.Add(base.UserInfo, itemEntity, out statusCode, out statusMessage); if (statusCode == StatusCode.OKAdd.ToString()) { if (SystemInfo.ShowSuccessMsg) { MessageBoxHelper.ShowSuccessMsg(statusMessage); } return(true); } else { MessageBoxHelper.ShowWarningMsg(statusMessage); if (statusCode == StatusCode.ErrorNameExist.ToString()) { this.txtFullName.SelectAll(); } else if (statusCode == StatusCode.ErrorCodeExist.ToString()) { this.txtCode.SelectAll(); } return(false); } } catch (Exception ex) { base.ProcessException(ex); return(false); } }
public IActionResult Add(DisplayToDoItem item) { var currUserId = userManager.GetUserId(User); if (ModelState.IsValid) { var newItem = new ToDoItem() { UserId = currUserId, Description = item.Description, Title = item.Title }; if (newItem.Description != null) { itemsService.Add(newItem); } } return(RedirectToAction("Add")); }
public IActionResult Post([FromBody] Product item) { itemsService.Add(item); return(CreatedAtRoute("GetProductLink", new { id = item.Id }, item)); }
public void Add([FromBody] ItemCreateModel model) { _service.Add(model.ToItem()); }
public void Add([FromBody] ItemModel model) { _service.Add(model.ToEntity()); }
public IActionResult Post([FromBody] Product item) //POST - dodaj nowy item { _itemService.Add(item); return(CreatedAtRoute("LinkToProduct", new { id = item.Id }, item)); }
public void AddItem(string text) { _service.Add(new Item(text)); }
public IEnumerable <ToDoItem> Add([FromBody] ToDoItem item) { itemsService.Add(item); return(itemsService.GetAll()); }
public IActionResult Add([FromForm] ItemModel item) { _service.Add(item.ToEntity()); return(RedirectToAction(nameof(Index))); }