public bool Insert(RemoteChillRequest item)
        {
            DateTimeOffset date = DateTime.Now;

            item.CreatedAt = item.UpdatedAt = DateTime.Now;
            Context.RemoteChillRequest.Add(item);
            int result = Context.SaveChanges();

            // Push notification time...
            RemoteChillRequestExteneded request = (from chillRequest in Context.RemoteChillRequest
                                                   join wine in Context.Wine.Include("WineVarietal") on chillRequest.MemberBottleID equals wine.Id
                                                   join locker in Context.LockerMember on chillRequest.LockerMemberID equals locker.Id
                                                   where chillRequest.Id == item.Id
                                                   select new RemoteChillRequestExteneded
            {
                ChillRequest = chillRequest,
                Wine = wine,
                Locker = locker
            }).First();

            if (result < 0)
            {
                return(false);
            }

            CustomNotificationController notifications = new CustomNotificationController();
            var requestPNS = $"Remote chill request {request.ChillRequest?.Description} for wine {request?.Wine?.WineTitle}({request?.Wine?.Vintage} - {request.Wine?.WineVarietal?.VarietalName}) from locker member {request?.Locker?.DisplayName} for {request?.ChillRequest?.RequestDate.ToString()}";

            notifications.DispatchNotification(NotificationType.APNS, $"{SealegsUserRole.AdminRole},{SealegsUserRole.ManagerRole}", requestPNS);
            notifications.DispatchNotification(NotificationType.GCM, $"{SealegsUserRole.AdminRole},{SealegsUserRole.ManagerRole}", requestPNS);

            return(result < 0 ? false : true);
        }
        public bool Delete(string id)
        {
            RemoteChillRequest original = Context.RemoteChillRequest.Find(id);

            if (original != null)
            {
                Context.Entry(original).CurrentValues.SetValues(original.Deleted = true);
                int result = Context.SaveChanges();
                return(result < 0 ? false : true);
            }
            return(false);
        }
Exemplo n.º 3
0
        public async Task <bool> InsertRemoteChillRequest(RemoteChillRequest chillRequest)
        {
            var form = new Dictionary <string, string>
            {
                { "RemoteChillRequestID", chillRequest.RemoteChillRequestID }, { "LockerMemberID", chillRequest.LockerMemberID },
                { "MemberBottleID", chillRequest.MemberBottleID }, { "RequestDate", Convert.ToString(chillRequest.RequestDate) },
                { "Description", chillRequest.Description }, { "IsCompleted", Convert.ToString(chillRequest.IsCompleted) },
                { "CompletedByID", Convert.ToString(chillRequest.CompletedByID) }
            };
            var result = await ClientBase.HttpPostRequest <bool>(InsertRemoteChillRequestUri, form);

            return(result);
        }
        public bool Update(RemoteChillRequest item)
        {
            item.UpdatedAt = DateTime.Now;
            RemoteChillRequest original = Context.RemoteChillRequest.Find(item.Id);

            if (original != null)
            {
                Context.Entry(original).CurrentValues.SetValues(item);
                int result = Context.SaveChanges();
                return(result < 0 ? false : true);
            }
            return(false);
        }