예제 #1
0
        public async Task <ActionResult> _Edit(EditSectorModel model)
        {
            var nameResponse = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Get, $"Administration/Sector/IsNameExist?id={model.Id}&name={model.Name}");

            if (nameResponse.isSuccess)
            {
                TempData["ErrorMessage"] = Language.Sector.ValidExistName;
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                var response = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Put, $"Administration/Sector?id={model.Id}", model);

                if (response.isSuccess)
                {
                    TempData["SuccessMessage"] = Language.Sector.AlertSuccessUpdate;

                    LogActivity(Modules.Setting, "Update Parameter Sector", model);

                    return(RedirectToAction("List"));
                }
            }

            TempData["ErrorMessage"] = Language.Sector.AlertFailUpdate;

            return(RedirectToAction("List"));
        }
예제 #2
0
        public ActionResult _Edit(int id, string No, string Name)
        {
            var model = new EditSectorModel
            {
                Id   = id,
                No   = No,
                Name = Name
            };

            return(View(model));
        }
예제 #3
0
        public IHttpActionResult Put(int id, [FromBody] EditSectorModel model)
        {
            var sector = db.Sector.Where(s => s.Id == id).FirstOrDefault();

            if (sector != null)
            {
                sector.Name = model.Name;

                db.Entry(sector).State = EntityState.Modified;
                db.Entry(sector).Property(x => x.Display).IsModified = false;

                db.SaveChanges();

                return(Ok(true));
            }
            else
            {
                return(NotFound());
            }
        }