Exemplo n.º 1
0
        public Event InsertEventModel(EventModel eventModel, string username)
        {
            Organisation organisation = oRepository.GetOrganisationByUsername(username);

            Location location = lRepository.GetLocationByAddressCity(eventModel.Address, eventModel.City);

            if (location == null && eventModel.Latitude > 0 && eventModel.Longitude > 0)
            {
                location = new Location()
                {
                    Lat        = eventModel.Latitude,
                    Lng        = eventModel.Longitude,
                    Address    = eventModel.Address,
                    City       = eventModel.City,
                    Country    = eventModel.Country,
                    PostalCode = int.Parse(eventModel.PostalCode)
                };

                lRepository.Add(location);
                lRepository.Complete();
                location = lRepository.GetLocationByAddressCity(eventModel.Address, eventModel.City);
            }

            Event eventDB = new Event()
            {
                Name                 = eventModel.Name,
                Description          = eventModel.Description,
                IdTypeEvent          = eventModel.IdTypeEvent,
                IdOrganisation       = organisation.Id,
                NoTickets            = eventModel.NoTickets,
                MoreDayEvent         = eventModel.MoreDayEvent,
                TimeEnd              = DateTime.Parse(eventModel.TimeEnd),
                TimeStart            = DateTime.Parse(eventModel.TimeStart),
                Wifi                 = eventModel.Wifi,
                Parking              = eventModel.Parking,
                Smoking              = eventModel.Smoking,
                WebUrl               = eventModel.WebUrl,
                Phone                = eventModel.Phone,
                Email                = eventModel.Email,
                ThirdPartyTickets    = eventModel.ThirdPartyTickets,
                ThirdPartyTicketsWeb = eventModel.ThirdPartyTicketsWeb
            };

            if (location != null)
            {
                eventDB.IdLocation = location.Id;
            }

            eRepository.Add(eventDB);
            eRepository.Complete();

            return(eventDB);
        }
Exemplo n.º 2
0
        public void SaveOrganisationOverViewModel(OrganisationOverviewModel orgModel)
        {
            Location location = lRepository.GetLocationByAddressCity(orgModel.Address, orgModel.City);

            if (location == null && orgModel.Latitude > 0 && orgModel.Longitude > 0)
            {
                location = new Location()
                {
                    Lat        = orgModel.Latitude,
                    Lng        = orgModel.Longitude,
                    Address    = orgModel.Address,
                    City       = orgModel.City,
                    Country    = orgModel.Country,
                    PostalCode = int.Parse(orgModel.PostalCode)
                };

                lRepository.Add(location);
                lRepository.Complete();
                location = lRepository.GetLocationByAddressCity(orgModel.Address, orgModel.City);
            }


            Organisation org = oRepository.Get(orgModel.Id);

            org.Name = orgModel.Name;
            org.IdTypeOrganisation = orgModel.IdTypeOrganisation;
            org.Description        = orgModel.Description;
            org.Email = orgModel.Email;
            if (location != null)
            {
                org.IdLocation = location.Id;
            }

            org.Phone = orgModel.Phone;
            org.Web   = orgModel.Web;

            //time
            org.PerDayWorkingHours    = orgModel.PerDayWorkingHours;
            org.WorkingHoursStart     = orgModel.WorkingHoursStart;
            org.WeekWorkingHoursStart = orgModel.WeekWorkingHoursStart;
            org.SunWorkingHoursStart  = orgModel.SunWorkingHoursStart;
            org.SatWorkingHoursStart  = orgModel.SatWorkingHoursStart;

            org.SatWorkingHoursEnd  = orgModel.SatWorkingHoursEnd;
            org.SunWorkingHoursEnd  = orgModel.SunWorkingHoursEnd;
            org.WeekWorkingHoursEnd = orgModel.WeekWorkingHoursEnd;
            org.WorkingHoursEnd     = orgModel.WorkingHoursEnd;

            oRepository.Complete();
        }