Communicates (notifies) the result of an action from the server to the client
Inheritance: System.Web.Mvc.JsonResult
Exemplo n.º 1
0
 public ActionResult Delete(ViewModel input)
 {
     var field = _repository.Find<Field>(input.EntityId);
     var rulesEngineBase = ObjectFactory.Container.GetInstance<RulesEngineBase>("DeleteFieldRules");
     var rulesResult = rulesEngineBase.ExecuteRules(field);
     if (!rulesResult.Success)
     {
         Notification notification = new Notification(rulesResult);
         return Json(notification);
     }
     _repository.SoftDelete(field);
     _repository.UnitOfWork.Commit();
     return null;
 }
Exemplo n.º 2
0
 public ActionResult ProcessEmail(ViewModel input)
 {
     var notification = new Notification{Success = true};
     var emailJob = _repository.Find<EmailJob>(input.EntityId);
     var emailTemplateHandler = ObjectFactory.Container.GetInstance<IEmailTemplateHandler>(emailJob.Name+"Handler");
     try{
         emailJob.GetSubscribers().Each(x=>
                                             {
                                                 var model = emailTemplateHandler.CreateModel(emailJob, x);
                                                 _emailService.SendSingleEmail(model);
                                             });
     }
     catch(Exception ex)
     {
         notification.Success = false;
         notification.Message = ex.Message;
     }
     return Json(notification, JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 3
0
 public Notification Finish()
 {
     var notification = new Notification { Success = true };
     GetCrudReports().Each(x =>
     {
         if (!x.Success)
         {
             notification.Success = false;
             if (notification.Errors == null)
                 notification.Errors = x.GetErrorInfos().ToList();
             else
                 x.GetErrorInfos().Each(notification.Errors.Add).ToList();
         }
     });
     if (notification.Success)
     {
         _repository.Commit();
         notification.Message = CoreLocalizationKeys.SUCCESSFUL_SAVE.ToString();
     }
     else
         _repository.Rollback();
     return notification;
 }
Exemplo n.º 4
0
 public ActionResult Login(LoginViewModel input)
 {
     var notification = new Notification
                            {Message = WebLocalizationKeys.INVALID_USERNAME_OR_PASSWORD.ToString()};
     if (input.HasCredentials())
     {
         var redirectUrl = string.Empty;
         var user = _securityDataService.AuthenticateForUserId(input.UserName, input.Password);
         if (user != null)
         {
             redirectUrl = _authContext.ThisUserHasBeenAuthenticated(user, input.RememberMe);
             notification.Success = true;
             notification.Message = string.Empty;
             notification.Redirect = true;
            _sessionContext.AddUpdateSessionItem(
             new SessionItem
                 {
                     SessionKey = WebLocalizationKeys.USER_ROLES.ToString(),
                     SessionObject = user.UserRoles
                 }
             );
         }
         if (redirectUrl != "/Home/Home")
         {
             notification.RedirectUrl = redirectUrl;
         }
         else if (user.UserType == UserType.Employee.ToString())
         {
             notification.RedirectUrl = UrlContext.GetUrlForAction<EmployeeDashboardController>(x => x.ViewEmployee(null)) + "/" + user.EntityId;
         }
         else
         {
             notification.RedirectUrl = redirectUrl;
         }
     }
     return Json(notification);
 }