Exemplo n.º 1
0
        public ActionResult Edit(int id, bool?isRedirected)
        {
            string role = new Business.AccountBusiness().currentMember();

            if (role == "U")
            {
                return(RedirectToAction("Login", "Account"));
            }
            TempData["pageName"]   = "Edit";
            TempData["facilityId"] = id;
            var facility = webApi.GetFacility(id);

            ViewBag.Areas         = new SelectList(webApi.GetAreas(), "AREA_ID", "AREA_NAME", facility.DISTRICT.CITY.AREA.AREA_ID);
            ViewBag.Cities        = new SelectList(webApi.GetCitiesByAreas(facility.DISTRICT.CITY.AREA.AREA_ID), "CITY_ID", "CITY_NAME", facility.DISTRICT.CITY.CITY_ID);
            ViewBag.Districts     = new SelectList(webApi.GetDistrictsByCities(facility.DISTRICT.CITY.CITY_ID), "DISTRICT_ID", "DISTRICT_NAME");
            ViewBag.FacilityTypes = new SelectList(webApi.GetFacilityTypes(), "FT_ID", "FT_NAME", facility.FACILITY_TYPE);

            if (isRedirected != true)
            {
                var facilityPictures = webApi.GetPicturesFromFacility(id);
                foreach (var item in facilityPictures)
                {
                    if (item.FP_PICTURE == "/img/FacilityPictures/no-photo.gif")
                    {
                        continue;
                    }
                    picturesPath.Add(item.FP_PICTURE);
                }
            }
            return(View(facility));
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            string role = new Business.AccountBusiness().currentMember();

            if (role == "U" || role == "A")
            {
                return(RedirectToAction("Login", "Account"));
            }
            var district = webApi.GetDistrict(id);

            ViewBag.Areas  = new SelectList(webApi.GetAreas(), "AREA_ID", "AREA_NAME", district.CITY.AREA.AREA_ID);
            ViewBag.Cities = new SelectList(webApi.GetCitiesByAreas(district.CITY.AREA.AREA_ID), "CITY_ID", "CITY_NAME");
            return(View(district));
        }
Exemplo n.º 3
0
        // GET: Member
        public ActionResult Index(int?pageActive, int?pageHistory, int?pageSub, int?selectedTab)
        {
            string role = new Business.AccountBusiness().currentMember();

            if (role != "U" && role != "A" && role != "O")
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (selectedTab != null)
            {
                TempData["selectedTab"] = selectedTab;
            }
            int pageSize          = 10;
            int pageNumberActive  = (pageActive ?? 1);
            int pageNumberHistory = (pageHistory ?? 1);
            int pageNumberSub     = (pageSub ?? 1);

            TempData["selectedTab"] = TempData["selectedTab"] == null ? 0 : TempData["selectedTab"];

            DatabaseEntities db = new DatabaseEntities();

            string     cookieName            = FormsAuthentication.FormsCookieName;
            HttpCookie authCookie            = HttpContext.Request.Cookies[cookieName];
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
            string userName         = ticket.Name;
            var    user             = webApi.GetUser(userName);
            var    liveReservations = webApi.liveReservations(user.USER_ID);
            var    subscribers      = webApi.GetSubscribersByUserId(user.USER_ID);
            var    oldReservations  = webApi.oldReservations(user.USER_ID);
            List <SportsSide.DAL.RESERVATION> newLiveReservations = new List <SportsSide.DAL.RESERVATION>();
            List <SportsSide.DAL.RESERVATION> newOldReservations  = new List <SportsSide.DAL.RESERVATION>();

            foreach (var item in liveReservations)
            {
                if (item.DT_BEGIN.Date > DateTime.Now.Date || (item.DT_BEGIN.Date == DateTime.Now.Date && item.DT_BEGIN.Hour > DateTime.Now.Hour))
                {
                    newLiveReservations.Add(item);
                }
            }
            foreach (var item in oldReservations)
            {
                if (item.DT_BEGIN.Date < DateTime.Now.Date || (item.DT_BEGIN.Date == DateTime.Now.Date && item.DT_BEGIN.Hour < DateTime.Now.Hour))
                {
                    newOldReservations.Add(item);
                }
            }
            MemberBigModel model = new MemberBigModel();

            model.User             = user;
            model.LiveReservations = newLiveReservations.OrderByDescending(x => x.CREATED_DATE).ToPagedList(pageNumberActive, pageSize);
            model.oldReservations  = newOldReservations.OrderByDescending(x => x.CREATED_DATE).ToPagedList(pageNumberHistory, pageSize);
            model.Subscribers      = subscribers.OrderByDescending(x => x.CREATED_DATE).ToPagedList(pageNumberSub, pageSize);
            model.selectedTab      = TempData["selectedTab"].ToString();

            model.Date = System.DateTime.Now.Date;


            ViewBag.Areas     = new SelectList(webApi.GetAreas(), "AREA_ID", "AREA_NAME", user.DISTRICT.CITY.AREA.AREA_ID);
            ViewBag.Cities    = new SelectList(webApi.GetCitiesByAreas(user.DISTRICT.CITY.AREA.AREA_ID), "CITY_ID", "CITY_NAME");
            ViewBag.Districts = new SelectList(webApi.GetDistrictsByCities(user.DISTRICT.CITY.CITY_ID), "DISTRICT_ID", "DISTRICT_NAME");

            return(View(model));
        }