Exemplo n.º 1
0
        public ActionResult Add(GalleryModel model)
        {
            CommonDataService cds = new CommonDataService();

            CommonModel cm = new CommonModel();

            cm = cds.GenerateCommonModel();
            Session["FaceBook"] = cm.FaceBook;
            Session["Twitter"] = cm.Twitter;
            Session["Youtube"] = cm.Youtube;
            Session["Instagram"] = cm.Instagram;
            Session["PhoneNumber"] = cm.PhoneNumber;
            Session["Email"] = cm.Email;
            Session["ShoppingHours"] = cm.ShoppingHours;
            GalleryDataService dataservice = new GalleryDataService();
            string galleryId = (string)Request.Form["edit_GalleryId"];
            string imageString = (string)Request.Form["edit_ImageString"];
            string galleryTitle = (string)Request.Form["edit_GalleryTitle"];
            string galleryDescription = (string)Request.Form["edit_GalleryDescription"];
            try
            {
                if (ModelState.IsValid)
                {
                    WebImage photo = null;
                    var newFileName = "";
                    var imagePath = "";

                    photo = WebImage.GetImageFromRequest();
                    if (photo != null)
                    {
                        newFileName = Guid.NewGuid().ToString() + "_" +
                            Path.GetFileName(photo.FileName);
                        imagePath = @"Contents\Images\Gallery\" + newFileName;

                        photo.Save(@"~\" + imagePath);
                        //model.ServicesId = int.Parse(serviceId);
                        model.ImageString = imagePath;

                    }
                    else
                    {
                        //model.ServicesId = int.Parse(serviceId);
                        model.ImageString = imageString;
                    }

                    dataservice.InsertGallery(model);
                    return RedirectToAction("Edit", "Gallery");
                }
                else
                {
                    //model.ServicesId = int.Parse(serviceId);
                    model.ImageString = imageString;
                    return View(model);
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                model = null;
                dataservice = null;
            }
        }
Exemplo n.º 2
0
        public ActionResult EditGallery(int galleryId)
        {
            CommonDataService cds = new CommonDataService();

            CommonModel cm = new CommonModel();

            cm = cds.GenerateCommonModel();
            Session["FaceBook"] = cm.FaceBook;
            Session["Twitter"] = cm.Twitter;
            Session["Youtube"] = cm.Youtube;
            Session["Instagram"] = cm.Instagram;
            Session["PhoneNumber"] = cm.PhoneNumber;
            Session["Email"] = cm.Email;
            Session["ShoppingHours"] = cm.ShoppingHours;
            GalleryModel model = new GalleryModel();
            GalleryDataService dataService = new GalleryDataService();
            try
            {
                model = dataService.GetGalleryById(galleryId);
                return View(model);
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                dataService = null;
            }
        }
Exemplo n.º 3
0
        // GET: Gallery
        public ActionResult Index()
        {
            CommonDataService cds = new CommonDataService();

            CommonModel cm = new CommonModel();

            cm = cds.GenerateCommonModel();
            Session["FaceBook"] = cm.FaceBook;
            Session["Twitter"] = cm.Twitter;
            Session["Youtube"] = cm.Youtube;
            Session["Instagram"] = cm.Instagram;
            Session["PhoneNumber"] = cm.PhoneNumber;
            Session["Email"] = cm.Email;
            Session["ShoppingHours"] = cm.ShoppingHours;
            GalleryDataService dataService = new GalleryDataService();
            GalleryViewModel viewModel = new GalleryViewModel();
            try
            {
                viewModel.GalleryModelRow1 = dataService.GenerateGalleryByRow(1);
                viewModel.GalleryModelRow2 = dataService.GenerateGalleryByRow(2);
                viewModel.GalleryModelRow3 = dataService.GenerateGalleryByRow(3);
                viewModel.GalleryModelRow4 = dataService.GenerateGalleryByRow(4);
                viewModel.GalleryModelRow5 = dataService.GenerateGalleryByRow(5);
                viewModel.GalleryModelRow6 = dataService.GenerateGalleryByRow(6);
                viewModel.GalleryModelRow7 = dataService.GenerateGalleryByRow(7);
                viewModel.GalleryModelRow8 = dataService.GenerateGalleryByRow(8);
                viewModel.GalleryModelRow9 = dataService.GenerateGalleryByRow(9);
                viewModel.GalleryModelRow10 = dataService.GenerateGalleryByRow(10);
                viewModel.GalleryModelRow11 = dataService.GenerateGalleryByRow(11);
                viewModel.GalleryModelRow12 = dataService.GenerateGalleryByRow(12);
                viewModel.GalleryModelRow13 = dataService.GenerateGalleryByRow(13);
                viewModel.GalleryModelRow14 = dataService.GenerateGalleryByRow(14);
                viewModel.GalleryModelRow15 = dataService.GenerateGalleryByRow(15);
                viewModel.GalleryModelRow16 = dataService.GenerateGalleryByRow(16);
                viewModel.GalleryModelRow17 = dataService.GenerateGalleryByRow(17);
                viewModel.GalleryModelRow18 = dataService.GenerateGalleryByRow(18);
                viewModel.GalleryModelRow19 = dataService.GenerateGalleryByRow(19);
                viewModel.GalleryModelRow20 = dataService.GenerateGalleryByRow(20);
                viewModel.GalleryModelRow21 = dataService.GenerateGalleryByRow(21);
                viewModel.GalleryModelRow22 = dataService.GenerateGalleryByRow(22);
                viewModel.GalleryModelRow23 = dataService.GenerateGalleryByRow(23);
                viewModel.GalleryModelRow24 = dataService.GenerateGalleryByRow(24);
                viewModel.GalleryModelRow25 = dataService.GenerateGalleryByRow(25);
                viewModel.GalleryModelRow26 = dataService.GenerateGalleryByRow(26);
                viewModel.GalleryModelRow27 = dataService.GenerateGalleryByRow(27);
                viewModel.GalleryModelRow28 = dataService.GenerateGalleryByRow(28);
                viewModel.GalleryModelRow29 = dataService.GenerateGalleryByRow(29);
                viewModel.GalleryModelRow30 = dataService.GenerateGalleryByRow(30);

                return View(viewModel);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Exemplo n.º 4
0
        public ActionResult DeleteGallery(int galleryId)
        {
            CommonDataService cds = new CommonDataService();

            CommonModel cm = new CommonModel();

            cm = cds.GenerateCommonModel();
            Session["FaceBook"] = cm.FaceBook;
            Session["Twitter"] = cm.Twitter;
            Session["Youtube"] = cm.Youtube;
            Session["Instagram"] = cm.Instagram;
            Session["PhoneNumber"] = cm.PhoneNumber;
            Session["Email"] = cm.Email;
            Session["ShoppingHours"] = cm.ShoppingHours;
            GalleryDataService dataService = new GalleryDataService();
            try
            {
                dataService.DeleteGallery(galleryId);
                return RedirectToAction("Edit", "Gallery");
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                dataService = null;
            }
        }