示例#1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            Hobli hobli = db.Hoblis.Find(id);

            db.Hoblis.Remove(hobli);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
 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;
 }
示例#3
0
 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));
 }
示例#4
0
        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));
        }
示例#5
0
        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;
            }
        }
示例#6
0
        // 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));
        }
示例#7
0
        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);
        }
示例#8
0
        // 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));
        }
示例#9
0
        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);
            }
        }
示例#10
0
        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);
            }
        }
示例#11
0
        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);
        }
示例#12
0
        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());
            }
        }
示例#13
0
 public async Task <int> DeleteHobliAsync(Hobli model)
 {
     _dataSource.Hoblis.Remove(model);
     return(await _dataSource.SaveChangesAsync());
 }