Пример #1
0
 public IHttpActionResult TerritoryDetail(int id)
 {
     try
     {
         using (var dataContext = new HuntingEntities())
         {
             var session = GetSession();
             if (session == null)
             {
                 return(Content(HttpStatusCode.Unauthorized, SESSION_INVALID_MESSAGE));
             }
             var userSession = AclUserContext.GetUserSession(dataContext, session);
             if (userSession == null)
             {
                 return(Content(HttpStatusCode.Unauthorized, SESSION_INVALID_MESSAGE));
             }
             var territory = TerritoryContext.GetDetail(dataContext, id);
             if (userSession.AclUser.CanViewTerritory(territory) == false)
             {
                 return(Content(HttpStatusCode.Forbidden, FORBIDDEN_MESSAGE));
             }
             var model = new TerritoryDetailModel(territory, userSession.AclUser);
             return(Ok(model));
         }
     }
     catch (Exception exception)
     {
         logger.Error(exception, "MobileController");
         return(InternalServerError());
     }
 }
 // GET: Territory/UpdateMap
 public ActionResult UpdateMap(int id)
 {
     try
     {
         using (var dataContext = new HuntingEntities())
         {
             var user = AclUserContext.GetDetail(dataContext, User.Identity.Name);
             if (user == null)
             {
                 ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED);
                 return(RedirectToAction("Index", "Home"));
             }
             var territory = TerritoryContext.GetDetail(dataContext, id);
             if (user.CanUpdateTerritory(territory) == false)
             {
                 ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED);
                 return(RedirectToAction("Index", "Home"));
             }
             var model = new TerritoryDetailModel(territory, user);
             return(View(model));
         }
     }
     catch (Exception exception)
     {
         logger.Error(exception, "TerritoryController");
         ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Danger, GlobalRes.ERROR_EXCEPTION);
         return(RedirectToAction("Index", "Home"));
     }
 }