Example #1
0
        public SubDevice UpdateSubDevice(string pk, string property, object value)
        {
            var pkid = int.Parse(pk);

            var entity = ProxylessContext.SubDevices.FirstOrDefault(x => x.PKID == pkid);

            if (entity == null)
            {
                throw new InvalidDataException("The SubDevice you are trying to update does not exist");
            }

            switch (property)
            {
            case "Name":
            case "FKReaderboardBackgroundImage":
                RootRepository.SecurityRepository.AssertDevicePermissions(entity.FKDevice);
                break;

            default:
                RootRepository.SecurityRepository.AssertSuperAdmin();
                break;
            }

            var ReflectionObject = entity.GetType();
            var propertyType     = ReflectionObject.GetProperty(property);

            propertyType.SetValue(entity, value, null);

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(entity);
        }
Example #2
0
        public HotelSlug AddHotelSlug(int hotelId, string name)
        {
            RootRepository.SecurityRepository.AssertSuperAdmin();

            if (ProxylessContext.HotelSlugs.Any(x => x.HotelSlugName.ToLower() == name.ToLower()))
            {
                throw new DuplicateNameException("A slug with this name already exists");
            }

            var hotel = ProxylessContext.Hotels.Include(x => x.HotelSlugs).FirstOrDefault(x => x.PKID == hotelId);

            if (hotel == null)
            {
                throw new InvalidDataException("The Hotel you are attempting to create a slug for does not exist");
            }

            var slug = new HotelSlug {
                HotelSlugName = name.ToLower(), Hotel = hotel
            };

            ProxylessContext.HotelSlugs.Add(slug);
            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(slug);
        }
Example #3
0
        public EventGroupManagerMap UpdateEventGroupManagerMap(string pk, string property, object value)
        {
            var pkid = int.Parse(pk);

            var entity =
                ProxylessContext.EventGroupManagerMaps.Include(x => x.EventGroup)
                .Include(x => x.ContactUser)
                .FirstOrDefault(x => x.PKID == pkid);

            if (entity == null)
            {
                throw new InvalidDataException("The EventGroupManagerMaps you are trying to update does not exist");
            }

            switch (property)
            {
            case "Email":
                RootRepository.SecurityRepository.AssertDevicePermissions(entity.EventGroup.FKDevice);
                break;

            default:
                RootRepository.SecurityRepository.AssertDevicePermissions(entity.EventGroup.FKDevice);
                break;
            }

            var ReflectionObject = entity.GetType();
            var propertyType     = ReflectionObject.GetProperty(property);

            propertyType.SetValue(entity, value, null);

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(entity);
        }
Example #4
0
        public Image UpdateConnectWebHeaderLogoImage(int hotelId, int?imageId)
        {
            RootRepository.SecurityRepository.AssertSuperAdmin();

            var hotelDetail = ProxylessContext.HotelDetails.FirstOrDefault(x => x.PKID == hotelId);

            if (hotelDetail == null)
            {
                throw new InvalidDataException("The Hotel you are attempting to update does not exist");
            }

            Image image = null;

            if (imageId.HasValue)
            {
                image = ProxylessContext.Images.FirstOrDefault(x => x.PKID == imageId.Value);
                if (image == null)
                {
                    throw new InvalidDataException("The Logo Image you are attempting to add does not exist");
                }

                hotelDetail.FKLogoConnectWebHeaderImage = image.PKID;
            }
            else
            {
                hotelDetail.FKLogoConnectWebHeaderImage = null;
            }

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);
            return(image);
        }
Example #5
0
        public SMSStockMessage SaveSMSStockMessage(int userId, SMSStockMessage message)
        {
            var result = RootRepository.HotelRepository.CheckHotelPermission(userId, message.FKHotel);

            if (result.Result == PermissionResults.Authorized)
            {
                if (message.PKID != 0)
                {
                    var msg = Rp.ExecuteAction(() => ProxylessContext.SMSStockMessages.FirstOrDefault(m => m.PKID == message.PKID));
                    if (msg != null)
                    {
                        msg.Name = message.Name;
                        msg.Text = message.Text;
                        ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId));
                        return(msg);
                    }
                }
                else
                {
                    var msg = new SMSStockMessage
                    {
                        Name    = message.Name,
                        Text    = message.Text,
                        FKHotel = message.FKHotel
                    };
                    ProxylessContext.SMSStockMessages.Add(msg);
                    ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId));
                    return(msg);
                }
            }
            return(null);
        }
Example #6
0
        public void DeleteScreenException(int userId, int id)
        {
            var exception = GetMarketingCampaignScreenException(userId, id).FirstOrDefault();

            if (exception != null)
            {
                ProxylessContext.MarketingCampaignExceptions.Remove(exception);
                ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId));
            }
        }
Example #7
0
        public void MapMobileBackgroundImage(int deviceId, Image image)
        {
            RootRepository.SecurityRepository.AssertDeviceAuthorization(deviceId);
            var hotelDetail =
                Rp.ExecuteAction(() => (from d in ProxylessContext.Devices where d.PKID == deviceId select d.Hotel.HotelDetail))
                .First();

            hotelDetail.MobileBackgroundImage = image;
            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);
        }
Example #8
0
        public void DeleteSMSStockMessage(int userId, int messageId)
        {
            var msg = GetSmsStockMessage(userId, messageId).FirstOrDefault();

            if (msg != null)
            {
                ProxylessContext.SMSStockMessages.Remove(msg);
                ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId));
            }
        }
Example #9
0
        public void DeleteScreen(int userId, int id)
        {
            var screen = GetMarketingCampaignScreen(userId, id).Include(x => x.MarketingCampaigns).FirstOrDefault();

            if (screen != null)
            {
                ProxylessContext.MarketingCampaignScreens.Remove(screen);
                ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId));
            }
        }
Example #10
0
        public void CompleteSetup()
        {
            var device = RootRepository.DeviceRepository.GetAdminDeviceForLoggedInUser();

            if (device != null)
            {
                var hd = ProxylessContext.HotelDetails.First(x => x.PKID == device.FKHotel);
                hd.SetupComplete = true;
                ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);
            }
        }
Example #11
0
        public EventDetail UpdateEventDetail(string pk, string property, object value)
        {
            var pkid = int.Parse(pk);

            var entity = ProxylessContext.EventDetails.FirstOrDefault(x => x.PKID == pkid);

            if (entity == null)
            {
                throw new InvalidDataException("The Event you are trying to update does not exist");
            }

            RootRepository.SecurityRepository.AssertDevicePermissions(entity.FKDevice);

            var ReflectionObject = entity.GetType();
            var propertyType     = ReflectionObject.GetProperty(property);

            switch (propertyType.PropertyType.Name)
            {
            case "DateTime":
                DateTime dt;
                if (!DateTime.TryParse(value.ToString(), out dt))
                {
                    throw new ArgumentException("Property expects a DateTime value");
                }

                dt = dt.ToUniversalTime();

                if (property == "LocalEndDateTime")
                {
                    var isAllDay = entity.LocalStartDateTime.TimeOfDay == new TimeSpan(0, 0, 0) &&
                                   dt.TimeOfDay == new TimeSpan(0, 0, 0) && entity.LocalStartDateTime <= dt;
                    if (isAllDay)
                    {
                        dt = dt.AddDays(1);
                    }
                }
                propertyType.SetValue(entity, dt, null);
                break;

            default:
                if (property == "RecurrenceRule" && entity.RecurrenceRule != value.ToString())
                {
                    var children = ProxylessContext.EventDetails.Where(x => x.FKRecurrenceParentId == entity.PKID).ToList();
                    children.ForEach(x => ProxylessContext.EventDetails.Remove(x));
                }
                propertyType.SetValue(entity, value, null);
                break;
            }

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(entity);
        }
Example #12
0
        public SMSTask CancelSMSTask(int userId, int taskId)
        {
            var task = GetSMSTask(taskId).Include(t => t.SMSJob).FirstOrDefault();

            if (task == null)
            {
                return(null);
            }
            task.Status            = SMSTaskStatus.CANCELLED;
            task.StatusLastUpdated = DateTime.UtcNow;
            ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId));
            return(task);
        }
Example #13
0
        public void UpdateEnterprise(int deviceId, EnterpriseModel enterprise, EnterpriseLocationModel enterpriseLocation)
        {
            if (enterprise != null)
            {
                RootRepository.SecurityRepository.AssertDevicePermissions(deviceId);

                UpdateEnterprise(enterprise);
                UpdateEnterpriseLocation(enterpriseLocation);

                Rp.ExecuteAction(
                    () => ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId));
            }
        }
Example #14
0
        public void UpdateHideConnectWebHeaderTitle(int hotelId, bool value)
        {
            RootRepository.SecurityRepository.AssertSuperAdmin();

            var hotelDetail = ProxylessContext.HotelDetails.FirstOrDefault(x => x.PKID == hotelId);

            if (hotelDetail == null)
            {
                throw new InvalidDataException("The Hotel you are attempting to update does not exist");
            }

            hotelDetail.HideConnectWebHeaderTitle = value;
            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);
        }
Example #15
0
        public void RemoveHotelImageMap(int mapId)
        {
            var map = ProxylessContext.HotelImageMaps.Include(x => x.Hotel.Devices).FirstOrDefault(x => x.Pkid == mapId);

            if (map == null)
            {
                throw new InvalidDataException("The image map you are trying to remove doesn't exist");
            }

            RootRepository.SecurityRepository.AssertDeviceAuthorization(map.Hotel.Devices.First().PKID);

            ProxylessContext.HotelImageMaps.Remove(map);

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);
        }
Example #16
0
        public void RemoveHotelImageMap(int mapId)
        {
            var map = ProxylessContext.HotelBrandImageMaps.FirstOrDefault(x => x.Pkid == mapId);

            if (map == null)
            {
                throw new InvalidDataException("The image map you are trying to remove doesn't exist");
            }

            RootRepository.SecurityRepository.AssertSuperAdmin();

            ProxylessContext.HotelBrandImageMaps.Remove(map);

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);
        }
Example #17
0
        public void RemoveHotelSlug(int slugId)
        {
            var slug = ProxylessContext.HotelSlugs.FirstOrDefault(x => x.PKID == slugId);

            if (slug == null)
            {
                throw new InvalidDataException("The hotel slug you are trying to remove doesn't exist");
            }

            RootRepository.SecurityRepository.AssertSuperAdmin();

            ProxylessContext.HotelSlugs.Remove(slug);

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);
        }
Example #18
0
        public HotelImageMap MapHotelImage(string path, string name, int width, int height, int hotelId)
        {
            var user  = RootRepository.SecurityRepository.GetLoggedInUser();
            var hotel =
                ProxylessContext.Hotels
                .Include(x => x.HotelImageMaps)
                .Include(x => x.Devices)
                .FirstOrDefault(h => h.PKID == hotelId);

            if (hotel == null)
            {
                throw new DataException("The section you are trying to modify does not exist");
            }

            if (!hotel.Devices.Any(x => RootRepository.SecurityRepository.HasDevicePermissions(x.PKID)))
            {
                throw new SecurityException("You are not authorized to access this hotel");
            }

            var image = new Image
            {
                FKAccount = user.FKAccount,
                Path      = path,
                Width     = width,
                Height    = height,
                Name      = name,
                IsActive  = true
            };

            var newOrdinal = hotel.HotelImageMaps.Count > 0
                                ? hotel.HotelImageMaps.Max(x => x.Ordinal) + 1
                                : 1;

            var map = new HotelImageMap
            {
                Hotel   = hotel,
                Image   = image,
                FKHotel = hotel.PKID,
                Ordinal = newOrdinal
            };

            ProxylessContext.Images.Add(image);
            ProxylessContext.HotelImageMaps.Add(map);
            hotel.HotelImageMaps.Add(map);
            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(map);
        }
Example #19
0
        public SMSJob SaveSMSJob(SMSJob job, string auditUser)
        {
            var numbers =
                Rp.ExecuteAction(
                    () =>
                    ProxylessContext.HotelDetails.Where(h => h.PKID == job.FKHotel)
                    .SelectMany(h => h.SMSWelcomeRequestType.SMSNumbers.Select(n => n.PhoneNumber)));
            SortedSet <SmsTimeSlot> timeslots = null;
            var taskStart = DateTime.UtcNow.AddMinutes(-1);
            var tasks     =
                Rp.ExecuteAction(() => ProxylessContext.SMSTasks.Where(x => numbers.Contains(x.FromPhone) && x.RunAt > taskStart && x.Status == SMSTaskStatus.SCHEDULED)).ToList();
            var existing = Rp.ExecuteAction(() => ProxylessContext.SMSJobs.Where(x => x.PKID == job.PKID)).FirstOrDefault();

            if (existing == null)
            {
                job.CreatedOn = DateTime.UtcNow;
                job.Status    = SMSJobStatus.INCOMPLETE;
                var availableNumbers = numbers.ToList();
                job.SMSTasks.ForEach(t =>
                {
                    t.Status     = SMSTaskStatus.SCHEDULED;
                    t.Message    = t.Message.Replace("{FirstName}", t.FirstName).Replace("{LastName}", t.LastName);
                    var timeslot = GetNextAvailableTaskTimeslot(availableNumbers, t.RunAt.ToUniversalTime(), t.Message.Length, tasks,
                                                                ref timeslots);
                    t.FromPhone         = timeslot.Item1;
                    t.RunAt             = timeslot.Item2;
                    t.StatusLastUpdated = DateTime.UtcNow;
                });
            }
            else
            {
                return(null);
            }

            if (job.SMSJobCallbacks.All(x => x.Url != "https://Connect.Monscierge.com/ConnectCMS/Request/NotifyTaskChanged"))
            {
                job.SMSJobCallbacks.Add(new SMSJobCallback {
                    Url = "https://Connect.Monscierge.com/ConnectCMS/Request/NotifyTaskChanged"
                });
            }

            ProxylessContext.SMSJobs.Add(job);
            ProxylessContext.LogValidationFailSaveChanges(string.Format(auditUser));
            SmsTaskTopicSender.GetHandle().NotifySmsTaskInserted();
            return(job);
        }
Example #20
0
        public NotificationJob CancelNotificationJob(int userId, int jobId)
        {
            if (CheckNotificationJobPermission(userId, jobId).Result != PermissionResults.Authorized)
            {
                return(null);
            }
            var job = GetNotificationJob(jobId).FirstOrDefault();

            if (job == null)
            {
                return(null);
            }

            job.Status = NotificationJobStatus.CANCELED;
            ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId));
            NotificationTopicSender.GetHandle().NotifyNotificationInserted();
            return(job);
        }
Example #21
0
        public IQueryable <BeaconUserNearby> GetNearbyUsers(int beaconId, TimeSpan?activeFor = null, bool deleteInactive = false)
        {
            var activeTill = activeFor.HasValue ? DateTime.UtcNow.Subtract(activeFor.Value) : DateTime.MinValue;

            if (deleteInactive)
            {
                var toDelete =
                    ProxylessContext.BeaconUsersNearby.Where(
                        x => x.FKBeacon == beaconId && x.EnteredOn < activeTill).ToList();
                toDelete.ForEach(x => ProxylessContext.BeaconUsersNearby.Remove(x));
                ProxylessContext.LogValidationFailSaveChanges(string.Format("B|{0}", beaconId));
            }

            return
                (ProxylessContext.BeaconUsersNearby.AsExpandable().Include(bun => bun.User)
                 .Where(b => b.FKBeacon == beaconId && b.EnteredOn > activeTill)
                 .OrderBy(bun => bun.EnteredOn));
        }
Example #22
0
        public HotelBrandImageMap MapHotelImage(string path, string name, int width, int height, int hotelBrandId)
        {
            var user       = RootRepository.SecurityRepository.GetLoggedInUser();
            var hotelBrand =
                ProxylessContext.HotelBrands
                .Include(x => x.HotelBrandImageMaps)
                .FirstOrDefault(h => h.PKID == hotelBrandId);

            if (hotelBrand == null)
            {
                throw new DataException("The section you are trying to modify does not exist");
            }

            RootRepository.SecurityRepository.AssertSuperAdmin();

            var image = new Image
            {
                FKAccount = user.FKAccount,
                Path      = path,
                Width     = width,
                Height    = height,
                Name      = name,
                IsActive  = true
            };

            var newOrdinal = hotelBrand.HotelBrandImageMaps.Count > 0
                                ? hotelBrand.HotelBrandImageMaps.Max(x => x.Ordinal) + 1
                                : 1;

            var map = new HotelBrandImageMap
            {
                HotelBrand   = hotelBrand,
                Image        = image,
                FKHotelBrand = hotelBrand.PKID,
                Ordinal      = newOrdinal
            };

            ProxylessContext.Images.Add(image);
            ProxylessContext.HotelBrandImageMaps.Add(map);
            hotelBrand.HotelBrandImageMaps.Add(map);
            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(map);
        }
Example #23
0
        public EventGroup UpdateEventGroup(string pk, string property, object value)
        {
            var pkid = int.Parse(pk);

            var entity = ProxylessContext.EventGroups.FirstOrDefault(x => x.PKID == pkid);

            if (entity == null)
            {
                throw new InvalidDataException("The EventGroup you are trying to update does not exist");
            }

            switch (property)
            {
            case "EventAccessCode":
                RootRepository.SecurityRepository.AssertEventGroupPemission(entity.PKID);
                value = value == null ? null : value.ToString().ToUpper().Trim();

                if (
                    ProxylessContext.EventGroups.FirstOrDefault(
                        x =>
                        x.FKDevice == entity.FKDevice && x.EventAccessCode != null &&
                        (x.EventAccessCode.ToUpper().Trim() == (( string )value)) && x.PKID != pkid) != null)
                {
                    throw new Exception("EventAccessCode already exists");
                }
                break;

            default:
                RootRepository.SecurityRepository.AssertDevicePermissions(entity.FKDevice);
                break;
            }

            var ReflectionObject = entity.GetType();
            var propertyType     = ReflectionObject.GetProperty(property);

            propertyType.SetValue(entity, value, null);

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(entity);
        }
Example #24
0
        public SMSTask RetrySMSTask(int userId, int taskId)
        {
            if (CheckSMSTaskPermission(userId, taskId).Result != PermissionResults.Authorized)
            {
                return(null);
            }
            var task = GetSMSTask(taskId).Include(t => t.SMSJob).Include(t => t.SMSJob.SMSJobCallbacks).FirstOrDefault();

            if (task == null)
            {
                return(null);
            }
            var nowWithBuffer  = DateTime.UtcNow.AddMinutes(-1);
            var scheduledTasks =
                GetSMSJobs(task.SMSJob.FKHotel)
                .SelectMany(
                    j => j.SMSTasks.Where(t => t.Status == SMSTaskStatus.SCHEDULED && t.RunAt > nowWithBuffer)).ToList();

            var hotel   = RootRepository.HotelRepository.GetHotelQuery(task.SMSJob.FKHotel).Include(x => x.HotelDetail.SMSWelcomeRequestType.SMSNumbers).FirstOrDefault();
            var numbers = hotel.HotelDetail.SMSWelcomeRequestType.SMSNumbers.Select(n => n.PhoneNumber).ToList();

            SortedSet <SmsTimeSlot> timeslots = null;
            var timeslot = GetNextAvailableTaskTimeslot(numbers, DateTime.UtcNow, task.Message.Length, scheduledTasks, ref timeslots);

            task.RunAt             = timeslot.Item2;
            task.FromPhone         = timeslot.Item1;
            task.Status            = SMSTaskStatus.SCHEDULED;
            task.StatusMessage     = null;
            task.MessageId         = null;
            task.StatusLastUpdated = DateTime.UtcNow;
            if (task.SMSJob.SMSJobCallbacks.All(x => x.Url != "https://Connect.Monscierge.com/ConnectCMS/Request/NotifyTaskChanged"))
            {
                task.SMSJob.SMSJobCallbacks.Add(new SMSJobCallback {
                    Url = "https://Connect.Monscierge.com/ConnectCMS/Request/NotifyTaskChanged"
                });
            }

            ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId));
            SmsTaskTopicSender.GetHandle().NotifySmsTaskInserted();
            return(task);
        }
Example #25
0
        public Hotel UpdateHotel(string pk, string property, object value)
        {
            var pkid = int.Parse(pk);

            var entity =
                ProxylessContext.Hotels.Include(h => h.Devices).FirstOrDefault(x => x.PKID == pkid);

            if (entity == null)
            {
                throw new InvalidDataException("The Hotel you are trying to update does not exist");
            }

            RootRepository.SecurityRepository.AssertDeviceAuthorization(entity.Devices.First().PKID);

            var ReflectionObject = entity.GetType();

            ReflectionObject.GetProperty(property).SetValue(entity, value, null);

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(entity);
        }
Example #26
0
        public SMSJob CancelSMSJob(int userId, int jobId)
        {
            if (CheckSMSJobPermission(userId, jobId).Result != PermissionResults.Authorized)
            {
                return(null);
            }
            var job   = GetSMSJob(jobId).Include(x => x.SMSTasks);
            var tasks = job.SelectMany(x => x.SMSTasks.Where(t => t.Status == SMSTaskStatus.SCHEDULED)).ToList();

            if (tasks.Count <= 0)
            {
                return(null);
            }
            tasks.ForEach(t =>
            {
                t.Status            = SMSTaskStatus.CANCELLED;
                t.StatusLastUpdated = DateTime.UtcNow;
            });
            ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId));
            SmsTaskTopicSender.GetHandle().NotifySmsTaskInserted();
            return(job.FirstOrDefault());
        }
Example #27
0
        public EventDetailSection UpdateEventDetailSection(string pk, string property, object value)
        {
            var pkid = int.Parse(pk);

            var entity =
                ProxylessContext.EventDetailSections.Include(section => section.EventDetail).FirstOrDefault(x => x.PKID == pkid);

            if (entity == null)
            {
                throw new InvalidDataException("The Event section you are trying to update does not exist");
            }

            RootRepository.SecurityRepository.AssertEventGroupPemission(entity.EventDetail.FKEventGroup);

            var ReflectionObject = entity.GetType();

            ReflectionObject.GetProperty(property).SetValue(entity, value, null);

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(entity);
        }
Example #28
0
        public MobileApp UpdateMobileApp(string pk, string property, object value)
        {
            var pkid = int.Parse(pk);

            var entity =
                ProxylessContext.MobileApps.FirstOrDefault(x => x.PKID == pkid);

            if (entity == null)
            {
                throw new InvalidDataException("The Mobile App you are trying to update does not exist");
            }

            RootRepository.SecurityRepository.AssertSuperAdmin();

            var ReflectionObject = entity.GetType();

            ReflectionObject.GetProperty(property).SetValue(entity, value, null);

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(entity);
        }
Example #29
0
        public void UpdateEnterprise(int deviceId, int enterpriseId, int?enterpriseLocationId, List <int> addedCategoryIds,
                                     List <int> removedCategoryIds)
        {
            if (addedCategoryIds != null || removedCategoryIds != null)
            {
                RootRepository.SecurityRepository.AssertDevicePermissions(deviceId);

                if (!enterpriseLocationId.HasValue)
                {
                    DeleteEnterpriseRecommendation(deviceId, enterpriseId, removedCategoryIds);
                    InsertEnterpriseRecommendation(deviceId, enterpriseId, addedCategoryIds);
                }
                else
                {
                    DeleteEnterpriseLocationRecommendation(deviceId, enterpriseId, enterpriseLocationId.Value, removedCategoryIds);
                    InsertEnterpriseLocationRecommendation(deviceId, enterpriseId, enterpriseLocationId.Value, addedCategoryIds);
                }

                Rp.ExecuteAction(
                    () => ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId));
            }
        }
Example #30
0
        public Hotel UpdateHotelSetup(Hotel model)
        {
            var hotel =
                Rp.ExecuteAction(
                    () => (from h in ProxylessContext.Hotels
                           .Include(h => h.HotelDetail)
                           .Include(h => h.HotelDetail.LogoImage)
                           .Include(h => h.HotelDetail.MobileBackgroundImage)
                           where h.PKID == model.PKID
                           select h).FirstOrDefault());

            hotel.Name = model.Name;

            string newLocalizedDescription, newDescription, newDescriptionLanguage;

            Localization.SetLocalizedText(hotel.HotelDetail.LocalizedDescription, hotel.HotelDetail.Description,
                                          hotel.HotelDetail.DescriptionLanguage, null, model.HotelDetail.Description, out newLocalizedDescription,
                                          out newDescription, out newDescriptionLanguage);

            hotel.HotelDetail.Description          = newDescription;
            hotel.HotelDetail.LocalizedDescription = newLocalizedDescription;
            hotel.HotelDetail.DescriptionLanguage  = newDescriptionLanguage;

            hotel.HotelDetail.FKLogoImage             = model.HotelDetail.FKLogoImage;
            hotel.HotelDetail.FKMobileBackgroundImage = model.HotelDetail.FKMobileBackgroundImage;

            hotel.HotelDetail.Phone = model.HotelDetail.Phone;

            hotel.HotelDetail.Address        = model.HotelDetail.Location.Address;
            hotel.HotelDetail.City           = model.HotelDetail.Location.City;
            hotel.HotelDetail.ISOCountryCode = model.HotelDetail.Location.ISOCountryCode;
            hotel.HotelDetail.State          = model.HotelDetail.Location.ISOStateCode;
            hotel.HotelDetail.Zip            = model.HotelDetail.Location.PostalCode;

            ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            return(GetHotelSetup(null, model.PKID));
        }