Ejemplo n.º 1
0
        public int UploadPackageImages(HttpPostedFileBase[] files, ImageType imgtype, string packageName)
        {
            string uploadDirectory = ConfigurationManager.AppSettings["UploadDirectoryImages"].ToString();

            using (camphorizonEntities db = new camphorizonEntities())
            {
                var order     = db.ImagesCatalogues.Where(x => x.ImageFor == (short)imgtype).Max(x => x.SlideOrder);
                int lastOrder = order.HasValue ? order.Value : 0;
                foreach (var img in files)
                {
                    string uploadFileLink = UploadFile(img, uploadDirectory);
                    lastOrder++;
                    db.ImagesCatalogues.Add(new ImagesCatalogue()
                    {
                        Active     = true,
                        ImageFor   = (short)imgtype,
                        ImageLink  = uploadFileLink,
                        Name       = packageName + " " + lastOrder.ToString(),
                        SlideOrder = (short)lastOrder
                    });
                }

                return(db.SaveChanges());
            }
        }
Ejemplo n.º 2
0
        public int UploadImages(ImageUploadViewModel model)
        {
            string uploadDirectory = ConfigurationManager.AppSettings["UploadDirectoryImages"].ToString();

            using (camphorizonEntities db = new camphorizonEntities())
            {
                var order     = db.ImagesCatalogues.Where(x => x.ImageFor == model.ImageType).Max(x => x.SlideOrder);
                int lastOrder = order.HasValue ? order.Value : 0;
                foreach (var img in model.Images)
                {
                    string uploadFileLink = UploadFile(img, uploadDirectory);
                    lastOrder++;
                    db.ImagesCatalogues.Add(new ImagesCatalogue()
                    {
                        Active       = model.Active,
                        ImageFor     = model.ImageType,
                        ImageLink    = uploadFileLink,
                        Name         = model.Name,
                        OfferDetails = model.OfferDetails,
                        OfferHeading = model.OfferHeading,
                        SlideOrder   = (short)lastOrder
                    });
                }

                return(db.SaveChanges());
            }
        }
Ejemplo n.º 3
0
        public int CreateAmmenities(AmmenitiesViewModel model)
        {
            using (camphorizonEntities db = new camphorizonEntities()) {
                db.Facilities.Add(new Facility()
                {
                    Facility1 = model.Name
                });

                return(db.SaveChanges());
            }
        }
Ejemplo n.º 4
0
        public int CreateCancellationTerm(CancellationTermViewModel model)
        {
            using (camphorizonEntities db = new camphorizonEntities())
            {
                db.CancellationTerms.Add(new CancellationTerm()
                {
                    CancellationTerm1 = model.CancellationTerm
                });

                return(db.SaveChanges());
            }
        }
Ejemplo n.º 5
0
 public int CreateReservationRequest(ReservationModel model)
 {
     using (camphorizonEntities db = new camphorizonEntities()) {
         db.ReservationRequests.Add(new ReservationRequest()
         {
             Adults       = model.Adults,
             CheckInDate  = model.CheckInDate,
             CheckOutDate = model.CheckOutDate,
             Children     = model.Children,
             Contact      = model.Contact,
             DateCreated  = DateTime.UtcNow,
             Email        = model.Email,
             ForDays      = (model.CheckOutDate - model.CheckInDate).Days
         });
         return(db.SaveChanges());
     }
 }
Ejemplo n.º 6
0
        public bool UpdateHomeConfiguration(WebPortalConfigurationsViewModel model)
        {
            using (camphorizonEntities db = new camphorizonEntities())
            {
                var config = db.ApplicationSettings.Where(x => x.Name == "Address").FirstOrDefault();
                config.Value           = model.Address;
                db.Entry(config).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                config                 = db.ApplicationSettings.Where(x => x.Name == "Helpline").FirstOrDefault();
                config.Value           = model.Contact;
                db.Entry(config).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                config                 = db.ApplicationSettings.Where(x => x.Name == "HelpEmail").FirstOrDefault();
                config.Value           = model.HelpEmail;
                db.Entry(config).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                config                 = db.ApplicationSettings.Where(x => x.Name == "WebsiteName").FirstOrDefault();
                config.Value           = model.WebsiteName;
                db.Entry(config).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                config                 = db.ApplicationSettings.Where(x => x.Name == "WelcomeText").FirstOrDefault();
                config.Value           = model.WelcomeText;
                db.Entry(config).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                config                 = db.ApplicationSettings.Where(x => x.Name == "AboutText").FirstOrDefault();
                config.Value           = model.AboutText;
                db.Entry(config).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(true);
            }
        }
Ejemplo n.º 7
0
        public bool CreatePackage(PackageViewModel model, string user)
        {
            bool isSave = false;

            using (camphorizonEntities db = new camphorizonEntities())
            {
                var package = new Package()
                {
                    Active      = model.Active,
                    CreatedBy   = user,
                    CreatedDate = DateTime.UtcNow,
                    Description = model.Description,
                    Duration    = model.Duration,
                    Name        = model.Name,
                    Price       = model.Price,
                    UpdatedBy   = user,
                    UpdatedDate = DateTime.UtcNow
                };

                db.Packages.Add(package);

                if (db.SaveChanges() > 0)
                {
                    isSave = true;
                }
                else
                {
                    isSave = false;
                }

                db.PackageInclusions.Add(new PackageInclusion()
                {
                    CreateDate = DateTime.UtcNow,
                    CreatedBy  = user,
                    Inclusions = model.Inclusions,
                    PackageID  = package.Id,
                    UpdateDate = DateTime.UtcNow,
                    UpdatedBy  = user
                });

                db.PackageItineraries.Add(new PackageItinerary()
                {
                    CreateDate = DateTime.UtcNow,
                    CreatedBy  = user,
                    Itinerary  = model.Itinerary,
                    PackageID  = package.Id,
                    UpdateDate = DateTime.UtcNow,
                    UpdatedBy  = user
                });

                db.PackageExclusions.Add(new PackageExclusion()
                {
                    CreateDate = DateTime.UtcNow,
                    CreatedBy  = user,
                    Exclusions = model.Exclusions,
                    PackageID  = package.Id,
                    UpdateDate = DateTime.UtcNow,
                    UpdatedBy  = user
                });

                if (UploadPackageImages(model.Images, ImageType.Package, model.Name) > 0)
                {
                    isSave = true;
                }
                else
                {
                    isSave = false;
                }

                foreach (var ammenity in model.Ammenities)
                {
                    if (ammenity.Checked)
                    {
                        db.PackageFacilityMappings.Add(new PackageFacilityMapping()
                        {
                            FacilityID = ammenity.Id, PackageID = package.Id
                        });
                    }
                }


                foreach (var ct in model.CancellationTerms)
                {
                    if (ct.Checked)
                    {
                        db.PackageCancellationTermsMappings.Add(new PackageCancellationTermsMapping()
                        {
                            CancellationTermID = ct.Id, PackageID = package.Id
                        });
                    }
                }



                if (db.SaveChanges() > 0)
                {
                    isSave = true;
                }
                else
                {
                    isSave = false;
                }
            }
            return(isSave);
        }