Exemple #1
0
        public ActionResult SaveOrEdit(Label label)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (label.Id == 0)
                    {
                        LabelRepository.Add(label);
                    }
                    else
                    {
                        LabelRepository.Edit(label);
                    }
                    LabelRepository.Save();

                    if (IsSuperAdmin)
                    {
                        return(RedirectToAction("Index", new { storeId = label.StoreId }));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Unable to save:" + ex.StackTrace, label);
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }


            return(View(label));
        }