Exemple #1
0
        public async Task <ActionResult <Item> > PutEmprestadoItem([FromQuery(Name = "id")] int id, [FromForm(Name = "rua")] string rua,
                                                                   [FromForm(Name = "numero")] string numero, [FromForm(Name = "complemento")] string complemento,
                                                                   [FromForm(Name = "estado")] string estado, [FromForm(Name = "cidade")] string cidade,
                                                                   [FromForm(Name = "nome")] string nome_emp, [FromForm(Name = "contato")] string contato_emp)
        {
            Item item = await _repositorio.Items.FindAsync(id);

            if (item == null)
            {
                return(BadRequest());
            }
            item.Rua                = rua;
            item.Numero             = Convert.ToInt32(numero);
            item.Complemento        = complemento;
            item.Estado             = estado;
            item.Cidade             = cidade;
            item.Nome_emprestado    = nome_emp;
            item.Contato_emprestado = contato_emp;
            item.Status             = "Emprestado";

            _repositorio.Entry(item).State = EntityState.Modified;
            await _repositorio.SaveChangesAsync();

            return(NoContent());
        }
Exemple #2
0
        public ActionResult EditItem(Item item)
        {
            if (item.IsComplate == true)
            {
                item.LastData = DateTime.Now;
            }


            db.Entry(item).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <ItemMaster> GetAsync(Guid itemMasterId)
        {
            var itemMaster = await _context.ItemMaster.FindAsync(itemMasterId);

            if (itemMaster != null)
            {
                await _context.Entry(itemMaster)
                .Reference(i => i.Type).LoadAsync();

                await _context.Entry(itemMaster)
                .Reference(i => i.UnitMeasure).LoadAsync();
            }

            return(itemMaster);
        }
        public IHttpActionResult PutItem(int id, Item item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != item.ID)
            {
                return(BadRequest());
            }

            db.Entry(item).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #5
0
        public IActionResult PutItem(int id, ClsMenuItem item)
        {
            if (id != item.ItemId)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;

            try
            {
                menuItems.Add(item);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutRecord(int id, Record record)
        {
            if (id != record.Id)
            {
                return(BadRequest());
            }

            _context.Entry(record).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RecordExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutItem(double id, Item item)
        {
            if (id != item.ItemId)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #8
0
        public async Task <IActionResult> PutItem([FromRoute] long id, [FromBody] Item item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != item.item_id)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #9
0
 public ActionResult Edit([Bind(Include = "id,name,description,cost,stock")] Item item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(item));
 }
Exemple #10
0
 public ActionResult Edit([Bind(Include = "FordonId,regNr,agare,fTyp,pDatum,pPlatsNr,startDatum,slutDatum,garageId")] Fordon fordon)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fordon).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(fordon));
 }
Exemple #11
0
 public ActionResult Edit([Bind(Include = "ItemCode,ItemName")] Item item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(item));
 }
        public ErrorMessage EditProduct(Product product, PicDetail pic)
        {
            ErrorMessage error = new ErrorMessage();

            error.IsSuccess = true;
            try
            {
                item.Entry(product).State = EntityState.Modified;
                item.Entry(pic).State     = EntityState.Modified;
                item.SaveChanges();
            }
            catch (Exception ex)
            {
                error.IsSuccess = false;
                error.Message   = ex.Message;
                return(error);
            }
            return(error);
        }
Exemple #13
0
 public ActionResult Edit([Bind(Include = "ID,Class,Make,Model,ShutterSpeed,PowerReq,Dimensions,Weight,Finish")] Item item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(item));
 }
 public ActionResult Edit([Bind(Include = "id_catalog_config,sku,max_saving_percentage,brand,name,special_price,price,activated_at,max_price,grouped_products,sizesystembrand,sizesystembrand_position,sub_cat_type_id,gender_id,attribute_set_id,categories,max_special_price,link,image,is_new,available_sizes")] Item item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(item));
 }
Exemple #15
0
 public ActionResult Edit([Bind(Include = "item_id,user_id,cart_date")] Cart cart)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cart).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cart));
 }
Exemple #16
0
 public ActionResult Edit([Bind(Include = "garageId,prisLiten,prisStor,antalPlatser")] Garage garage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(garage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(garage));
 }
 public ActionResult Edit([Bind(Include = "TtId,DateTime,Lesson1,Lesson2,Lesson3,Lesson4")] Timetable timetable)
 {
     if (ModelState.IsValid)
     {
         db.Entry(timetable).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TtId = new SelectList(db.SchoolClass, "SCId", "Name", timetable.TtId);
     return(View(timetable));
 }
 public ActionResult Edit([Bind(Include = "TeId,LoginId,FName,SName,PassWD")] Teacher teacher)
 {
     if (ModelState.IsValid)
     {
         teacher.PassWD          = Helpers.Sha1.Encode(teacher.PassWD);
         db.Entry(teacher).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(teacher));
 }
Exemple #19
0
        public async Task <IActionResult> UpdateItem(long id, ItemModel model)
        {
            if (id != model.Id)
            {
                return(BadRequest());
            }

            _itemContext.Entry(model).State = EntityState.Modified;
            await _itemContext.SaveChangesAsync();

            return(NoContent());
        }
        public async Task <IActionResult> PutItem(long id, ASPItem todoItem)
        {
            if (id != todoItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(todoItem).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "StId,LoginId,FName,SName,PassWD,SCId")] Student student)
 {
     if (ModelState.IsValid)
     {
         student.PassWD          = Helpers.Sha1.Encode(student.PassWD);
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SCId = new SelectList(db.SchoolClass, "SCId", "Name", student.SCId);
     return(View(student));
 }
 public ActionResult Edit([Bind(Include = "SCId,Name,TeId")] SchoolClass schoolClass)
 {
     if (ModelState.IsValid)
     {
         db.Entry(schoolClass).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TeId = new SelectList(db.Teacher, "TeId", "LoginId", schoolClass.TeId);
     ViewBag.SCId = new SelectList(db.Timetable, "TtId", "Lesson1", schoolClass.SCId);
     return(View(schoolClass));
 }
        public async Task <IStoreItem> StoreAsync(IStoreItem storeItem, CancellationToken cancellationToken)
        {
            if (storeItem == null)
            {
                throw new ArgumentNullException(nameof(storeItem));
            }

            cancellationToken.ThrowIfCancellationRequested();

            var existingEntity = await FindTrackedEntityBy(storeItem.Id);

            if (existingEntity == null)
            {
                var newEntity = toEntityConverter.ToEntity(storeItem);
                dbContext.Add(newEntity);

                await dbContext.SaveChangesAsync();

                var e = GetItemQuery().First(i => i.Id == newEntity.Id);
                e.Predecessor = await LoadPredecessorsAsync(e);

                return(toModelConverter.ToDomain(e));
            }
            else
            {
                var updatedEntity = toEntityConverter.ToEntity(storeItem);
                dbContext.Entry(existingEntity).CurrentValues.SetValues(updatedEntity);
                dbContext.Entry(existingEntity).State = EntityState.Modified;

                UpdateOrAddAvailabilities(existingEntity, updatedEntity);
                DeleteAvailabilities(existingEntity, updatedEntity);

                await dbContext.SaveChangesAsync();

                var e = GetItemQuery().First(i => i.Id == updatedEntity.Id);
                e.Predecessor = await LoadPredecessorsAsync(e);

                return(toModelConverter.ToDomain(e));
            }
        }
  public async Task <IActionResult>  PutMenuItem(long id,  Item item)
  
 {
      if (id  !=  item.Id)
       {
          return BadRequest();
          
     }
      _context.Entry(item).State  =  EntityState.Modified;
      await _context.SaveChangesAsync();
      return NoContent();
      
 }
        public async Task <IActionResult> EndOrder([FromRoute] int id)
        {
            var order = await _context.Orders.FindAsync(id);

            order.IsDone = true;

            _context.Entry(order).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderExists(id))
                {
                    return(NotFound());
                }

                throw;
            }

            return(Ok("Order changed"));
        }
Exemple #26
0
        public ErrorMessage EditOrder(Order order)
        {
            ErrorMessage error = new ErrorMessage();

            error.IsSuccess = true;
            try
            {
                item.Entry(order).State = EntityState.Modified;
                item.SaveChanges();
            }
            catch (Exception ex)
            {
                error.IsSuccess = false;
                error.Message   = ex.Message;
                return(error);
            }
            return(error);
        }
        // PUT: api/Item/5
        public int Put(Item item)
        {
            if (ModelState.IsValid)
            {
                using (ItemContext db = new ItemContext())
                {
                    db.Entry(item).State = EntityState.Modified;
                    try
                    {
                        db.SaveChanges();
                        return(1);
                    }
                    catch (Exception)
                    {
                        return(0);

                        throw;
                    }
                }
            }
            return(0);
        }
Exemple #28
0
 bool IItemRepository.Alterar(Item item)
 {
     context.Entry(item).State = EntityState.Modified;
     return(true);
 }
Exemple #29
0
 public void Create(T Enity)
 {
     _context.Entry(Enity).State = EntityState.Added;
 }