public ActionResult UserGuestUpdate(int?id)
        {
            LocationHandler lh = new LocationHandler();

            ViewBag.CountryList = ModelHelper.ToSelectItemList(lh.GetCountries());

            User u = (User)Session[WebUtil.CURRENT_USER];

            if (u != null && u.IsInRole(WebUtil.ADMIN_ROLE))
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                return(RedirectToAction("UserEdit", new { id = u.Id }));
            }
            else if (u != null && !(u.IsInRole(WebUtil.ADMIN_ROLE)))
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                User user = new UserHandler().GetUserById(id);
                if (user == null)
                {
                    return(HttpNotFound());
                }
                ViewBag.HideSlider = true;
                return(View(user));
            }
            ViewBag.HideSlider = true;
            return(View());
        }
Beispiel #2
0
        public ActionResult SignUp()
        {
            LocationHandler lh = new LocationHandler();

            ViewBag.CountryList = ModelHelper.ToSelectItemList(lh.GetCountries());

            return(View());
        }
        // GET: Company/Create
        public ActionResult AddCompany()
        {
            User u = (User)Session[WebUtil.CURRENT_USER];

            if (!(u != null && u.IsInRole(WebUtil.ADMIN_ROLE)))
            {
                return(RedirectToAction("Login", "User", new { ctl = "Admin", act = "AdminPanel" }));
            }
            LocationHandler lh = new LocationHandler();

            ViewBag.CountryList = ModelHelper.ToSelectItemList(lh.GetCountries());
            return(View());
        }
        public ActionResult AddCompany(FormCollection fdata)
        {
            User u = (User)Session[WebUtil.CURRENT_USER];

            if (!(u != null && u.IsInRole(WebUtil.ADMIN_ROLE)))
            {
                return(RedirectToAction("Login", "User", new { ctl = "Admin", act = "AdminPanel" }));
            }
            LocationHandler lh = new LocationHandler();

            ViewBag.CountryList = ModelHelper.ToSelectItemList(lh.GetCountries());
            try
            {
                Company c = new Company
                {
                    Name            = fdata["Name"],
                    Description     = fdata["Description"],
                    FacebookPageUrl = fdata["FacebookPageUrl"],
                    City            = new City {
                        Id = Convert.ToInt32(fdata["CityList"])
                    }
                };
                long numb  = DateTime.Now.Ticks;
                int  count = 0;
                foreach (string fname in Request.Files)
                {
                    HttpPostedFileBase file = Request.Files[fname];
                    if (!string.IsNullOrEmpty(file?.FileName))
                    {
                        string url  = "/ImagesData/CompanyImages/" + numb + "_" + ++count + file.FileName.Substring(file.FileName.LastIndexOf(".", StringComparison.Ordinal));
                        string path = Request.MapPath(url);
                        file.SaveAs(path);
                        c.ImageUrl = url;
                    }
                    else
                    {
                        string url = "/ImagesData/CompanyImages/noimage2.jpg";
                        c.ImageUrl = url;
                    }
                }
                new CompanyHandler().AddCompany(c);
                return(RedirectToAction("CompanyManagment"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult UserEdit(int?id)
        {
            LocationHandler lh = new LocationHandler();

            ViewBag.CountryList = ModelHelper.ToSelectItemList(lh.GetCountries());
            User u = (User)Session[WebUtil.CURRENT_USER];

            if (!(u != null && u.IsInRole(WebUtil.ADMIN_ROLE)))
            {
                return(RedirectToAction("Login", "User", new { ctl = "Home", act = "Index" }));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            User user = new UserHandler().GetUserById(id);

            if (user == null)
            {
                return(HttpNotFound());
            }
            return(View(user));
        }