Example #1
0
        /// <summary>
        /// general reminder edit method
        /// </summary>
        /// <param name="reminder">gets the changes of the reminder to save it</param>
        /// <returns>index view</returns>
        public ActionResult GeneralReminderUpdate(GeneralRemindersViewModel reminder)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    reminder.ModifyOn = DateTime.Now;
                    reminder.ModifyBy = 1;


                    //The model is valid - update the reminder and redisplay the grid.
                    ReminderService.GeneralReminderUpdate(reminder);

                    //GridRouteValues() is an extension method which returns the
                    //route values defining the grid state - current page, sort expression, filter etc.

                    return(RedirectToAction("Index", ReminderService.Read()));
                }
                else
                {
                    List <string> Errors = new List <string>();

                    foreach (ModelState modelState in ViewData.ModelState.Values)
                    {
                        foreach (ModelError error in modelState.Errors)
                        {
                            Errors.Add(error.ErrorMessage);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            //The model is invalid - render the current view to show any validation errors
            return(View());
        }