Example #1
0
        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));
        }
Example #3
0
        public IActionResult Add(AddItemInputModel inputModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            _itemsService.Add(inputModel);

            return(Redirect(Items_Root_Path));
        }
Example #4
0
        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);
            }
        }
Example #5
0
        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"));
        }
Example #6
0
        public IActionResult Post([FromBody] Product item)
        {
            itemsService.Add(item);

            return(CreatedAtRoute("GetProductLink", new { id = item.Id }, item));
        }
Example #7
0
 public void Add([FromBody] ItemCreateModel model)
 {
     _service.Add(model.ToItem());
 }
Example #8
0
 public void Add([FromBody] ItemModel model)
 {
     _service.Add(model.ToEntity());
 }
Example #9
0
        public IActionResult Post([FromBody] Product item) //POST - dodaj nowy item
        {
            _itemService.Add(item);

            return(CreatedAtRoute("LinkToProduct", new { id = item.Id }, item));
        }
Example #10
0
 public void AddItem(string text)
 {
     _service.Add(new Item(text));
 }
Example #11
0
 public IEnumerable <ToDoItem> Add([FromBody] ToDoItem item)
 {
     itemsService.Add(item);
     return(itemsService.GetAll());
 }
Example #12
0
 public IActionResult Add([FromForm] ItemModel item)
 {
     _service.Add(item.ToEntity());
     return(RedirectToAction(nameof(Index)));
 }