public ActionResult Delete_Confirm(int id)
        {
            var strError = string.Empty;

            if (id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            try
            {
                _mainStore.Delete(id);

                //Clear cache
                CachingHelpers.ClearProviderCache();
            }
            catch (Exception ex)
            {
                strError = NotifSettings.Error_SystemBusy;

                logger.Error("Failed to get Delete Provider because: " + ex.ToString());

                return(Json(new { success = true, message = strError }));
            }

            return(Json(new { success = true, message = NotifSettings.Success_Deleted }));
        }
        public ActionResult Edit(ProviderEditModel model)
        {
            if (!ModelState.IsValid)
            {
                string messages = string.Join("; ", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage + x.Exception));
                this.AddNotification(messages, NotificationType.ERROR);
                return(View(model));
            }

            try
            {
                //Begin db transaction
                var shopInfo = ExtractEditFormData(model);

                var isSuccess = _mainStore.Update(shopInfo);
                if (isSuccess)
                {
                    //Clear cache
                    CachingHelpers.ClearProviderCache();

                    this.AddNotification(NotifSettings.Success_Updated, NotificationType.SUCCESS);
                }
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed for Edit Provider POST request: " + ex.ToString());
            }

            return(RedirectToAction("Edit/" + model.Id));
        }
        public ActionResult Create(ProviderCreateModel model)
        {
            var newId = 0;

            if (!ModelState.IsValid)
            {
                string messages = string.Join("; ", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage + x.Exception));
                this.AddNotification(messages, NotificationType.ERROR);
                return(View(model));
            }

            try
            {
                //Begin db transaction
                var info = ExtractCreateFormData(model);

                newId = _mainStore.Insert(info);
                if (newId > 0)
                {
                    //Clear cache
                    CachingHelpers.ClearProviderCache();

                    this.AddNotification(NotifSettings.Success_Created, NotificationType.SUCCESS);
                }
                else
                {
                    this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);
                }
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed for Create request: " + ex.ToString());

                return(View(model));
            }

            return(RedirectToAction("Edit/" + newId));
        }