Ejemplo n.º 1
0
        public ActionResult DeleteLanguage(string buttonYes, string buttonNo, Guid id)
        {
            if (buttonYes != null)
            {
                try
                {
                    LocalizationService.Delete(LocalizationService.Get(id));
                    Context.SaveChanges();
                    ShowSuccess("Language Deleted");
                }
                catch (Exception ex)
                {
                    Context.RollBack();
                    ShowError(ex.Message);
                    LoggingService.Error(ex);
                }
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteLanguage1(Guid Id)
        {
            var language = LocalizationService.Get(Id);

            if (language == null)
            {
                return(RedirectToAction("Index"));
            }

            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    LocalizationService.Delete(language);

                    unitOfWork.Commit();
                    LocalizationService.Clear();
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message     = LocalizationService.GetResourceString("Xóa gói ngôn ngữ thành công"),
                        MessageType = GenericMessages.success
                    };
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    unitOfWork.Rollback();
                    LoggingService.Error(ex.Message);
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message     = LocalizationService.GetResourceString("Có lỗi xảy ra!"),
                        MessageType = GenericMessages.warning
                    };
                }
            }

            return(View(language));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteLanguage(string buttonYes, string buttonNo, Guid id)
        {
            if (buttonYes != null)
            {
                using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
                {
                    try
                    {
                        LocalizationService.Delete(LocalizationService.Get(id));
                        unitOfWork.Commit();
                        ShowSuccess("Language Deleted");
                    }
                    catch (Exception ex)
                    {
                        unitOfWork.Rollback();
                        ShowError(ex.Message);
                        LoggingService.Error(ex);
                    }
                }
            }

            return(RedirectToAction("Index"));
        }