예제 #1
0
        public ActionResult Edit(SportsSide.DAL.FACILITY model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var result = webApi.PutFacility(model);

            if (result == false)
            {
                TempData["Hata"] = "Bir hata oluştu.";
                var facility = webApi.GetFacility(model.FACILITY_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");
                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);
                return(View(model));
            }

            SportsSide.DAL.FACILITY_PICTURES pictureModel = new SportsSide.DAL.FACILITY_PICTURES();
            pictureModel.F_ID = model.FACILITY_ID;
            webApi.DeleteAllFacilityPicturesFromId(model.FACILITY_ID);
            foreach (var path in picturesPath)
            {
                pictureModel.FP_PICTURE = path;
                result = webApi.PostFacilityPicture(pictureModel);
                if (result == false)
                {
                    TempData["Hata"] = "Bir hata oluştu.";
                    return(View(model));
                }
            }
            if (picturesPath.Count == 0)
            {
                pictureModel.FP_PICTURE = "/img/FacilityPictures/no-photo.gif";
                result = webApi.PostFacilityPicture(pictureModel);
                if (result == false)
                {
                    TempData["Hata"] = "Bir hata oluştu";
                    return(View(model));
                }
            }
            return(RedirectToAction("Index", "Facilities"));
        }
예제 #2
0
        public ActionResult Create(SportsSide.DAL.FACILITY model)
        {
            string     cookieName            = FormsAuthentication.FormsCookieName;           //Find cookie name
            HttpCookie authCookie            = HttpContext.Request.Cookies[cookieName];       //Get the cookie by it's name
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); //Decrypt it
            string UserName = ticket.Name;                                                    //You have the UserName!
            var    user     = webApi.GetUser(UserName);

            model.USER_ID = user.USER_ID;
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var result = webApi.PostFacility(model);

            if (result == false)
            {
                TempData["Hata"] = "Bir hata oluştu.";
                return(View(model));
            }
            SportsSide.DAL.FACILITY_PICTURES pictureModel = new SportsSide.DAL.FACILITY_PICTURES();
            pictureModel.F_ID = model.FACILITY_ID;
            foreach (var path in picturesPath)
            {
                pictureModel.FP_PICTURE = path;
                result = webApi.PostFacilityPicture(pictureModel);
                if (result == false)
                {
                    TempData["Hata"] = "Bir hata oluştu.";
                    return(View(model));
                }
            }
            if (picturesPath.Count == 0)
            {
                pictureModel.FP_PICTURE = "/img/FacilityPictures/no-photo.gif";
                result = webApi.PostFacilityPicture(pictureModel);
                if (result == false)
                {
                    TempData["Hata"] = "Bir hata oluştu";
                    return(View(model));
                }
            }
            return(RedirectToAction("Index", "Facilities"));
        }