public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
        {
            if (filterContext == null)
            {
                throw new ArgumentNullException("filterContext");
            }

            if (filterContext.HttpContext.User.Identity.IsAuthenticated)
            {
                ClaimsPrincipal webUser  = (ClaimsPrincipal)filterContext.HttpContext.User;
                string          webEmail = webUser.FindFirst("preferred_username")?.Value;
                if (webEmail == null)
                {
                    throw new ArgumentNullException("Missing e-mail !");
                }

                var DBusersNo = _service.GetAll <UserListDto>().Count();
                // No users => enable UsersController operations
                if (DBusersNo == 0 && filterContext.HttpContext.Request.Url.AbsolutePath.IndexOf("/Users") == 0)
                {
                    return;
                }
                var DBuser = _service.GetAll <UserListDto>().FirstOrDefault(u => u.Mail == webEmail);

                HttpRequestBase request = filterContext.RequestContext.HttpContext.Request;
                if (DBuser != null)
                {
                    Log.Info($"{DBuser.Mail} {request.HttpMethod} {request.Url}.");
                    return;
                }
                else
                {
                    Log.Warn($"!{webEmail} attempt to {request.HttpMethod} {request.Url}");
                }
            }
            else
            {
                // auth failed, redirect to login page
                filterContext.Result = new HttpUnauthorizedResult();
                return;
            }

            ViewDataDictionary viewData = new ViewDataDictionary
            {
                { "Message", "You do not have sufficient privileges." }
            };

            filterContext.Result = new ViewResult {
                MasterName = this.MasterName, ViewName = this.ViewName, ViewData = viewData
            };
        }
Beispiel #2
0
        // GET: Product
        public ActionResult Index(IListService service)
        {
            var dataForList = new ProductListSupportDataModel(ProductListFilters.AvailableForSale,
                                                              service.GetAll <ProductCategory>());

            return(View(dataForList));
        }
        public JsonResult GetCompanies(string text, IListService service)
        {
            var companies = service.GetAll <ListCustomerDto>();

            return(string.IsNullOrEmpty(text)
                ? Json(companies, JsonRequestBehavior.AllowGet)
                : Json(companies.Where(p => p.CompanyName.Contains(text)), JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public void LoadCategories()
        {
            var cat = new SearchCriteria <ListDTO>();

            cat.FiList.Add(c => c.Type == ListType);
            var liList = _listService.GetAll(cat).ToList();

            Lists = new ObservableCollection <ListDTO>(liList);
        }
        //-----------------------------------------------
        public JsonResult GetProducts(string text, IListService service)
        {
            var products =
                service.GetAll<Product>()
                    .Select(x => new KeyTextClass<int> {Key = x.ProductID, Text = x.ProductNumber + " (" + x.ProductCategory.Name + ", " + x.Name + ")"});

            return string.IsNullOrEmpty(text)
                ? Json(products, JsonRequestBehavior.AllowGet)
                : Json(products.Where(p => p.Text.Contains(text)), JsonRequestBehavior.AllowGet);
        }
Beispiel #6
0
        //-----------------------------------------------


        public JsonResult GetProducts(string text, IListService service)
        {
            var products =
                service.GetAll <Product>()
                .Select(x => new KeyTextClass <int> {
                Key = x.ProductID, Text = x.ProductNumber + " (" + x.ProductCategory.Name + ", " + x.Name + ")"
            });

            return(string.IsNullOrEmpty(text)
                ? Json(products, JsonRequestBehavior.AllowGet)
                : Json(products.Where(p => p.Text.Contains(text)), JsonRequestBehavior.AllowGet));
        }
Beispiel #7
0
        /// <summary>
        /// Note that is Index is different in that it has an optional id to filter the list on.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        public ActionResult Index(int?id, IListService service)
        {
            var filtered = id != null && id != 0;
            var query    = filtered ? service.GetAll <SimplePostDto>().Where(x => x.BlogId == id) : service.GetAll <SimplePostDto>();

            if (filtered)
            {
                TempData["message"] = "Filtered list";
            }

            return(View(query.ToList()));
        }
Beispiel #8
0
        public HttpResponseMessage GetAll()
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, ModelState));
            }

            ItemsResponse <ToDoListDomain> Response = new ItemsResponse <ToDoListDomain>();

            Response.Items = listService.GetAll();
            return(Request.CreateResponse(HttpStatusCode.OK, Response));
        }
Beispiel #9
0
        public List<ListListVM> GetListType(string type)
        {

            var _lists = _listsService.GetAll();
            var _listInfo = _listLanguageService.GetAll();

            var listTypes = (from l in _lists
                             join li in _listInfo on l.Id equals li.Id
                             where l.Type == type
                             select new ListListVM { Id = l.Id, Type = l.Type, Value = li.Value });

            return listTypes.ToList();

        }
Beispiel #10
0
        public HttpResponseMessage GetAll()
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, ModelState));
            }

            ItemsResponse <ListTypeModel> Response = new ItemsResponse <ListTypeModel>();

            Response.Items = systemDicionaryService.GetAll();

            if (Response.Items != null)
            {
                foreach (var item in Response.Items)
                {
                    item.ToDoList = listService.GetAll().Where(p => p.ListTypeId == item.Id).ToList();
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK, Response));
        }
        public JsonResult IndexListRead([DataSourceRequest] DataSourceRequest request, IListService service)
        {
            var result = service.GetAll <ListCustomerDto>().OrderBy(x => x.CustomerID).ToDataSourceResult(request);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #12
0
        /// <summary>
        /// reads only the SalesOrderDetail for the given sales order
        /// </summary>
        /// <param name="request"></param>
        /// <param name="salesOrderId"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        public JsonResult ReadLineItems([DataSourceRequest] DataSourceRequest request, int salesOrderId, IListService service)
        {
            var result = service.GetAll <CrudSalesOrderDetailDto>().Where(x => x.SalesOrderID == salesOrderId).OrderBy(x => x.SalesOrderDetailID).ToDataSourceResult(request);

            return(Json(result));
        }
        public JsonResult GetCompanies(string text, IListService service)
        {
            var companies = service.GetAll<ListCustomerDto>();

            return string.IsNullOrEmpty(text)
                ? Json(companies, JsonRequestBehavior.AllowGet)
                : Json(companies.Where(p => p.CompanyName.Contains(text)), JsonRequestBehavior.AllowGet);
        }
 public JsonResult IndexListReadVer2([DataSourceRequest]DataSourceRequest request, IListService service)
 {
     var result = service.GetAll<ListCustomerVer2Dto>().OrderBy(x => x.CustomerID).ToDataSourceResult(request);
     return Json(result, JsonRequestBehavior.AllowGet);
 }
 public ActionResult Index(IListService service)
 {
     return View(service.GetAll<BlogListDto>().ToList());
 }
 public ActionResult AjaxProductDescriptionRead([DataSourceRequest]DataSourceRequest request, IListService service)
 {
     return Json(service.GetAll<ProductDescription>().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
 }
 // GET: TagsAsync
 public async Task<ActionResult> Index(IListService service)
 {
     return View(await service.GetAll<TagListDto>().ToListAsync());
 }
 /// <summary>
 /// reads only the SalesOrderDetail for the given sales order
 /// </summary>
 /// <param name="request"></param>
 /// <param name="salesOrderId"></param>
 /// <param name="service"></param>
 /// <returns></returns>
 public JsonResult ReadLineItems([DataSourceRequest]DataSourceRequest request, int salesOrderId, IListService service)
 {
     var result = service.GetAll<CrudSalesOrderDetailDto>().Where(x => x.SalesOrderID == salesOrderId).OrderBy(x => x.SalesOrderDetailID).ToDataSourceResult(request);
     return Json(result);
 }
 // GET: Product
 public ActionResult Index(IListService service)
 {
     var dataForList = new ProductListSupportDataModel(ProductListFilters.AvailableForSale,
         service.GetAll<ProductCategory>());
     return View(dataForList);
 }
 public JsonResult IndexListRead([DataSourceRequest]DataSourceRequest request, IListService service)
 {
     var result = service.GetAll<ListProductDto>().OrderBy( x => x.ProductID).ToDataSourceResult(request);
     return Json(result);
 }
Beispiel #21
0
        public JsonResult IndexListRead([DataSourceRequest] DataSourceRequest request, IListService service)
        {
            var result = service.GetAll <ListProductDto>().OrderBy(x => x.ProductID).ToDataSourceResult(request);

            return(Json(result));
        }
        /// <summary>
        /// Note that is Index is different in that it has an optional id to filter the list on.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        public ActionResult Index(int? id, IListService service)
        {
            var filtered = id != null && id != 0;
            var query = filtered ? service.GetAll<SimplePostDto>().Where(x => x.BlogId == id) : service.GetAll<SimplePostDto>();
            if (filtered)
                TempData["message"] = "Filtered list";

            return View(query.ToList());
        }
Beispiel #23
0
 // GET: TagsAsync
 public async Task <ActionResult> Index(IListService service)
 {
     return(View(await service.GetAll <TagListDto>().ToListAsync()));
 }
 public ActionResult Index(IListService service)
 {
     return(View(service.GetAll <BlogListDto>().ToList()));
 }
 public IActionResult Get()
 {
     return(Json(_listService.GetAll()));
 }
Beispiel #26
0
 public ActionResult AjaxProductDescriptionRead([DataSourceRequest] DataSourceRequest request, IListService service)
 {
     return(Json(service.GetAll <ProductDescription>().ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
 }