public ActionResult DeleteConfirmed(Guid id) { Hobli hobli = db.Hoblis.Find(id); db.Hoblis.Remove(hobli); db.SaveChanges(); return(RedirectToAction("Index")); }
private void UpdateHobliFromModel(Hobli target, HobliModel source) { target.HobliId = source.HobliId; target.HobliGuid = source.HobliGuid; target.HobliName = source.HobliName; target.HobliGMapLink = source.HobliGMapLink; target.HobliIsActive = source.HobliIsActive; target.TalukId = Convert.ToInt32(source.TalukId); target.TalukName = source.TalukName; }
public ActionResult Edit([Bind(Include = "Id,Name,TalukId")] Hobli hobli) { if (ModelState.IsValid) { db.Entry(hobli).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TalukId = new SelectList(DataFilter.GetTaluks(TempData.Peek("Id") + ""), "Id", "Name", hobli.TalukId); return(View(hobli)); }
public ActionResult Create([Bind(Include = "Id,Name,TalukId")] Hobli hobli) { if (ModelState.IsValid) { hobli.Id = Guid.NewGuid(); db.Hoblis.Add(hobli); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TalukId = new SelectList(DataFilter.GetTaluks(TempData.Peek("Id") + ""), "Id", "Name", hobli.TalukId); return(View(hobli)); }
public async Task <int> UpdateHobliAsync(Hobli model) { try { _dataSource.Entry(model).State = EntityState.Modified; int res = await _dataSource.SaveChangesAsync(); return(res); } catch (Exception ex) { throw ex; } }
// GET: Hoblis/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Hobli hobli = db.Hoblis.Find(id); if (hobli == null) { return(HttpNotFound()); } return(View(hobli)); }
static public async Task <HobliModel> CreateHobliModelAsync(Hobli source, bool includeAllFields) { var model = new HobliModel() { HobliId = source.HobliId, HobliGuid = source.HobliGuid, HobliName = source.HobliName, HobliGMapLink = source.HobliGMapLink, HobliIsActive = source.HobliIsActive, TalukId = source.TalukId.ToString(), TalukName = source.TalukName }; return(model); }
// GET: Hoblis/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Hobli hobli = db.Hoblis.Find(id); if (hobli == null) { return(HttpNotFound()); } ViewBag.TalukId = new SelectList(DataFilter.GetTaluks(TempData.Peek("Id") + ""), "Id", "Name", hobli.TalukId); return(View(hobli)); }
public async Task <HobliModel> AddHobliAsync(HobliModel model) { using (var dataService = DataServiceFactory.CreateDataService()) { var hobli = new Hobli(); if (hobli != null) { UpdateHobliFromModel(hobli, model); hobli.HobliGuid = Guid.NewGuid(); hobli.HobliId = await dataService.AddHobliAsync(hobli); model.Merge(await GetHobliAsync(dataService, hobli.HobliId)); } return(model); } }
public async Task <HobliModel> UpdateHobliAsync(HobliModel model) { long id = model.HobliId; using (var dataService = DataServiceFactory.CreateDataService()) { var hobli = new Hobli(); if (hobli != null) { UpdateHobliFromModel(hobli, model); await dataService.UpdateHobliAsync(hobli); model.Merge(await GetHobliAsync(dataService, hobli.HobliId)); } return(model); } }
public async Task <int> AddHobliAsync(Hobli model) { if (model == null) { return(0); } var entity = new Hobli() { HobliId = model.HobliId, HobliGuid = model.HobliGuid, TalukId = model.TalukId, HobliName = model.HobliName, HobliGMapLink = model.HobliGMapLink, HobliIsActive = model.HobliIsActive, }; _dataSource.Entry(entity).State = EntityState.Added; int res = await _dataSource.SaveChangesAsync(); return(res); }
public async Task <Result> DeleteHobliAsync(HobliModel model) { var hobli = new Hobli { HobliId = model.HobliId }; using (var dataService = DataServiceFactory.CreateDataService()) { try { await dataService.DeleteHobliAsync(hobli); } catch (DbUpdateException ex) when(ex.InnerException is SqlException sqlException && (sqlException.Number == 547)) { return(Result.Error("Hobli is already in use")); } catch (Exception ex) { throw ex; } return(Result.Ok()); } }
public async Task <int> DeleteHobliAsync(Hobli model) { _dataSource.Hoblis.Remove(model); return(await _dataSource.SaveChangesAsync()); }