public ActionResult <IEnumerable <NewItemViewModel> > PutTodoItem(long id, NewItemViewModel newItem)
        //public async Task<IActionResult> PutTodoItem(long id, TodoItem todoItem)
        {
            if (id != newItem.Id)
            {
                return(BadRequest());
            }


            /*  try
             * {
             *    await _context.SaveChangesAsync();
             * }
             * catch (DbUpdateConcurrencyException)
             * {
             *    if (!TodoItemExists(id))
             *    {
             *        return NotFound();
             *    }
             *    else
             *    {
             *        throw;
             *    }
             * }*/
            var newIntemBModels = new NewItemBLLModel();

            newIntemBModels.Name        = newItem.Name.ToUpper();
            newIntemBModels.createdDate = newItem.createdDate; //.ToString();
            newIntemBModels.Size        = newItem.Size;
            newIntemBModels.Price       = newItem.Price;
            _NewItemService.Update(newIntemBModels);

            return(Ok(newIntemBModels));
        }
        public void AddNewItem(NewItemBLLModel model)
        {
            var item = new NewItem()
            {
                Id          = model.Id,
                Name        = model.Name,
                createdDate = model.createdDate,
                Size        = model.Size,
                Price       = model.Price
            };

            context.NewItem.Add(item);
            context.SaveChanges();
        }
        public ActionResult PostTodoItem(NewItemViewModel newItem)

        //public Task<ActionResult<NewItemViewModel>> PostTodoItem(NewItemViewModel newItem)
        {
            var newIntemBModels = new NewItemBLLModel();

            newIntemBModels.Name        = newItem.Name.ToUpper();
            newIntemBModels.createdDate = newItem.createdDate; //.ToString();
            newIntemBModels.Size        = newItem.Size;
            newIntemBModels.Price       = newItem.Price;
            _NewItemService.Add(newIntemBModels);

            return(Ok(newIntemBModels));
            //return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem);
        }
Beispiel #4
0
        public void UpdateNewItem(NewItemBLLModel model)
        {
            var item = context.NewItem
                       .Where(p => p.Id == model.Id).FirstOrDefault();

            if (item != null)
            {
                context.Entry(item).CurrentValues.SetValues(model);
                context.SaveChanges();
            }
            else
            {
                throw new KeyNotFoundException();
            }
        }
Beispiel #5
0
        NewItemBLLModel InewItemService.FetchById(long id)
        {
            var result = new NewItemBLLModel();

            try
            {
                //    result = _dataAccessService.f.FetchEmployee(id);
                result = _dataAccessService.findNewItem(id);
            }
            catch (Exception e)
            {
            }

            return(result);
        }
        NewItemBLLModel InewItemService.FetchById(long id)
        {
            var result = new NewItemBLLModel();

            //try
            //{
            //    result = _dataAccessService.f.FetchEmployee(id);

            //}
            //catch (Exception e)
            //{
            //    //
            //}

            return(result);
        }
Beispiel #7
0
        NewItemBLLModel IDALService.findNewItem(long id)
        {
            //var item = context.NewItem.FindAsync(id);
            var item = context.NewItem
                       .Where(p => p.Id == id).FirstOrDefault();
            NewItemBLLModel returnObject = null;

            if (item != null)
            {
                returnObject = new NewItemBLLModel()
                {
                    Id          = item.Id,
                    Name        = item.Name,
                    createdDate = item.createdDate,
                    Size        = item.Size,
                    Price       = item.Price,
                    Pic         = item.Pic
                };
            }


            return(returnObject);
        }
 public void Add(NewItemBLLModel model)
 {
     _dataAccessService.AddNewItem(model);
 }
 public void Update(NewItemBLLModel model)
 {
     _dataAccessService.UpdateNewItem(model);
 }
 public void UpdateNewItem(NewItemBLLModel model)
 {
     throw new System.NotImplementedException();
 }