public async Task <ActionResult> Edit()
        {
            EditSLAReminderModel model = new EditSLAReminderModel
            {
                Id                = Convert.ToInt32(Request["item.Id"]),
                ETCode            = Request["item.ETCode"],
                SLAResolutionTime = Convert.ToInt32(Request["SLAResolutionTime"]),
                IntervalDuration  = Convert.ToInt32(Request["IntervalDuration"]),
                SLADurationType   = (SLADurationType)Convert.ToInt32(Request["item.SLADurationType"])
            };

            if (model != null)
            {
                var response = await WepApiMethod.SendApiAsync <EditSLAReminderModel>(HttpVerbs.Put, $"Reminder/SLA/?id={model.Id}", model);

                if (response.isSuccess)
                {
                    await LogActivity(Modules.Setting, "Update SLA Reminder Settings");

                    TempData["SuccessMessage"] = "SLA Reminder updated successfully";

                    return(RedirectToAction("List", new { pin = model.Id }));
                }
                else
                {
                    TempData["ErrorMessage"] = "Failed to update SLA Reminder Settings";
                    return(RedirectToAction("List"));
                }
            }
            else
            {
                TempData["ErrorMessage"] = "Failed to update SLA Reminder Settings";
                return(RedirectToAction("List"));
            }
        }
Exemplo n.º 2
0
        // PUT: api/SLAReminder/5
        public IHttpActionResult Put(int id, EditSLAReminderModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (id != model.Id)
            {
                return(BadRequest());
            }

            SLAReminder obj = db.SLAReminder.Find(model.Id);

            obj.ETCode            = model.ETCode;
            obj.IntervalDuration  = model.IntervalDuration;
            obj.SLADurationType   = model.SLADurationType;
            obj.SLAResolutionTime = model.SLAResolutionTime;

            db.Entry(obj).State = EntityState.Modified;
            db.Entry(obj).Property(x => x.ETCode).IsModified            = true;
            db.Entry(obj).Property(x => x.IntervalDuration).IsModified  = true;
            db.Entry(obj).Property(x => x.SLADurationType).IsModified   = true;
            db.Entry(obj).Property(x => x.SLAResolutionTime).IsModified = true;

            db.Configuration.ValidateOnSaveEnabled = true;
            db.SaveChanges();

            return(Ok());
        }