public ActionResult LibrariesDelete(LibrariesModel model)
 {
     if (Session["UserTicket"] != null)
     {
         model.deleteLibrary(model, new Guid(Session["UserTicket"].ToString()));
         return(Redirect("~/Libraries/Libraries"));
     }
     return(Redirect("~/Login/Login"));
 }
 public ActionResult LibrariesAdd()
 {
     if (Session["UserTicket"] != null && Session["UserId"] != null)
     {
         LibrariesModel model = new LibrariesModel();
         return(View(model));
     }
     return(Redirect("~/Login/Login"));
 }
        // GET: Libraries

        public ViewResult Libraries(string sortOrder, string currentFilter, string searchString, int?page)
        {
            if (Session["UserTicket"] != null)
            {
                ViewBag.CurrentSort  = sortOrder;
                ViewBag.IdSortParm   = String.IsNullOrEmpty(sortOrder) ? "id_asc" : "";
                ViewBag.NameSortParm = sortOrder == "Name" ? "Name_desc" : "Name";

                if (searchString != null)
                {
                    page = 1;
                }
                else
                {
                    searchString = currentFilter;
                }

                ViewBag.CurrentFilter = searchString;

                LibrariesModel m = new LibrariesModel();

                var libraries = m.getLibraries(new Guid(Session["UserTicket"].ToString()));

                if (!String.IsNullOrEmpty(searchString))
                {
                    libraries = libraries.Where(s => s.Name.Contains(searchString) ||
                                                s.Id.ToString().Contains(searchString) ||
                                                s.AdditionalInfo.Contains(searchString));
                }
                switch (sortOrder)
                {
                case "id_asc":
                    libraries = libraries.OrderByDescending(s => s.Id);
                    break;

                case "Name":
                    libraries = libraries.OrderBy(s => s.Name);
                    break;

                case "Name_desc":
                    libraries = libraries.OrderByDescending(s => s.Name);
                    break;

                default:      // id ascending
                    libraries = libraries.OrderBy(s => s.Id);
                    break;
                }

                int pageSize   = 6;
                int pageNumber = (page ?? 1);
                return(View(libraries.ToPagedList(pageNumber, pageSize)));
            }

            RedirectToAction("Login", "login");
            return(View());
        }
 public ActionResult LibrariesEdit(LibrariesModel model)
 {
     if (Session["UserTicket"] != null)
     {
         if (model.Name != null)
         {
             model.UserId = (int)Session["UserId"];
             model.editLibrary(model, new Guid(Session["UserTicket"].ToString()));
             return(Redirect("~/Libraries/Libraries"));
         }
         return(View(model));
     }
     return(Redirect("~/Login/Login"));
 }
        public ActionResult LibrariesEdit(int id)
        {
            if (Session["UserTicket"] != null)
            {
                DataQueryService.IDataQueryService dataQueryService = new DataQueryService.DataQueryServiceClient();

                var library = dataQueryService.GetLibrary(id, new Guid(Session["UserTicket"].ToString()));

                LibrariesModel model = new LibrariesModel();

                model.Id             = library.Id;
                model.AdditionalInfo = library.AdditionalInfo;
                model.Address        = library.Address;
                model.Name           = library.Name;
                model.OpeningHours   = library.OpeningHours;
                model.UserId         = model.UserId;

                return(View(model));
            }
            return(Redirect("~/Login/Login"));
        }