public Task DeleteAsync(int id) { var de = GetByIdAsync(id); context.Entry(de.Result).State = EntityState.Deleted; return(context.SaveChangesAsync()); }
public async Task <IActionResult> PutTagv2(int id, Tag tag) { if (id != tag.Id) { return(BadRequest()); } _context.Entry(tag).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult SubCities_Update([DataSourceRequest] DataSourceRequest request, SubCity subCity) { if (ModelState.IsValid) { var entity = new SubCity { SubCityId = subCity.SubCityId, Name = subCity.Name, Code = subCity.Code }; db.SubCities.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return(Json(new[] { subCity }.ToDataSourceResult(request, ModelState))); }
public ActionResult UnitOfMeasurements_Update([DataSourceRequest] DataSourceRequest request, UnitOfMeasurement unitOfMeasurement) { if (ModelState.IsValid) { var entity = new UnitOfMeasurement { UnitOfMeasurementId = unitOfMeasurement.UnitOfMeasurementId, Name = unitOfMeasurement.Name, Code = unitOfMeasurement.Code, Symbol = unitOfMeasurement.Symbol, Weight = unitOfMeasurement.Weight }; db.UnitOfMeasurements.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return(Json(new[] { unitOfMeasurement }.ToDataSourceResult(request, ModelState))); }
public ActionResult CommodityCategories_Update([DataSourceRequest] DataSourceRequest request, CommodityCategory commodityCategory) { if (ModelState.IsValid) { var entity = new CommodityCategory { CommodityCategoryId = commodityCategory.CommodityCategoryId, Name = commodityCategory.Name, Code = commodityCategory.Code, Description = commodityCategory.Description, Remark = commodityCategory.Remark }; db.CommodityCategories.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return(Json(new[] { commodityCategory }.ToDataSourceResult(request, ModelState))); }
public ActionResult Commodities_Update([DataSourceRequest] DataSourceRequest request, Commodity commodity) { if (ModelState.IsValid) { var entity = new Commodity { CommodityId = commodity.CommodityId, Name = commodity.Name, Code = commodity.Code, UnitOfMeasurementId = commodity.UnitOfMeasurementId, CommodityCategoryId = commodity.CommodityCategoryId }; db.Commodities.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return(Json(new[] { commodity }.ToDataSourceResult(request, ModelState))); }
public ActionResult Weredas_Update([DataSourceRequest] DataSourceRequest request, Wereda wereda) { if (ModelState.IsValid) { var entity = new Wereda { WeredaId = wereda.WeredaId, Code = wereda.Code, Name = wereda.Name, SubcityId = wereda.SubcityId, Description = wereda.Description, Remark = wereda.Remark }; db.Weredas.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return(Json(new[] { wereda }.ToDataSourceResult(request, ModelState))); }
public ActionResult Markets_Update([DataSourceRequest] DataSourceRequest request, Market market) { if (ModelState.IsValid) { var entity = new Market { MarketId = market.MarketId, Name = market.Name, Code = market.Code, WeredaId = market.WeredaId, SubcityId = market.SubcityId, Description = market.Description, Remark = market.Remark }; db.Markets.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return(Json(new[] { market }.ToDataSourceResult(request, ModelState))); }