Пример #1
0
        public static CommonSite SiteToCommon(Sites site)
        {
            CommonSite commonSite = new CommonSite()
            {
                SiteId        = site.SiteId,
                Name          = site.Name,
                Description   = site.Description,
                Category      = site.Category,
                Area          = site.Area,
                AddressGMaps  = site.AddressGMaps,
                OpeningHour   = site.OpeningHour,
                ClosingHour   = site.ClosingHour,
                EstimatedStay = site.EstimatedStay,
                Price         = site.Price
            };

            commonSite.Equipment = new List <string>();
            foreach (EquipmentSites e in site.EquipmentSites)
            {
                commonSite.Equipment.Add(DataEquipment.GetEquipmentNameById(e.EquipmentId));
                //commonSite.EquipmentSites = new List<CommonEquipmentSite>();
                //commonSite.EquipmentSites.Add(EquipmentSiteToCommon(e));
            }
            //foreach (TripSite ts in site.TripSite)
            //{
            //    commonSite.TripSite = new List<CommonTripSite>();
            //    commonSite.TripSite.Add(TripSiteToCommon(ts));
            //}
            return(commonSite);
        }
Пример #2
0
        /****************Site***********************/
        public static Sites SiteToDB(CommonSite commonSite)
        {
            Sites site = new Sites()
            {
                SiteId        = commonSite.SiteId,
                Name          = commonSite.Name,
                Description   = commonSite.Description,
                Category      = commonSite.Category,
                Area          = commonSite.Area,
                AddressGMaps  = commonSite.AddressGMaps,
                OpeningHour   = commonSite.OpeningHour,
                ClosingHour   = commonSite.ClosingHour,
                EstimatedStay = commonSite.EstimatedStay,
                Price         = commonSite.Price,
            };

            site.EquipmentSites = new List <EquipmentSites>();
            foreach (String e in commonSite.Equipment)
            {
                EquipmentSites equipmentSites = new EquipmentSites
                {
                    SiteId      = site.SiteId,
                    EquipmentId = DataEquipment.GetEquipmentIdByName(e)
                };
                site.EquipmentSites.Add(equipmentSites);
            }
            //foreach(CommonTripSite ts in commonSite.TripSite)
            //{
            //    site.TripSite = new List<TripSite>();
            //    site.TripSite.Add(TripSiteToDB(ts));
            //}
            return(site);
        }
Пример #3
0
        public static Boolean AddSite(CommonSite site)
        {
            dbEntities db = new dbEntities();

            try
            {
                Sites newSite = Mapper.SiteToDB(site);
                db.Sites.Add(newSite);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
Пример #4
0
 // POST: api/Trips
 public Boolean Post([FromBody] CommonSite site)
 {
     return(AdminManager.AddSite(site));
 }
Пример #5
0
 public static Boolean AddSite(CommonSite s)
 {
     return(DataSite.AddSite(s));
 }