コード例 #1
0
        public async void UpdateUserFCM(string fcm)
        {
            using (var client = new RestfulClient())
            {
                UserDTO user = DataBase.Instance.Query <UserDTO>().FirstOrDefault();
                user.FCM             = fcm;
                user.ISFCMDeprecated = true;
                DataBase.Instance.Update(user);

                if (user.IsRegistered)
                {
                    RegisterUserDTO register = new RegisterUserDTO()
                    {
                        FcmId = user.FCM
                    };
                    ResponseModel model = await _rc.PostDataAsync(PostActionMethods.UpdateFCM, register);

                    if (model.IsSuccessStatusCode)
                    {
                        user.ISFCMDeprecated = false;
                        DataBase.Instance.Update(user);
                    }
                }
            }
        }
コード例 #2
0
        public async Task <bool> Confirm(int orderID)
        {
            ResponseModel response = await _rc.PostDataAsync(Enums.PostActionMethods.ReplyOrder, new ReplyOrderDTO { Answer = true, OrderID = orderID });

            if (response.IsSuccessStatusCode)
            {
                ReponseDTO data = JsonConvert.DeserializeObject <ReponseDTO>(response.ResponseContent);
                if (data.Response)
                {
                    NotificationDTO item = DataBase.Instance.Query <NotificationDTO>().First(x => x.NotificationID == orderID);
                    item.IsOrderPending  = false;
                    item.IsOrderAccepted = true;
                    DataBase.Instance.Update(item);
                }

                return(data.Response);
            }
            else
            {
                return(response.IsSuccessStatusCode);
            }
        }
コード例 #3
0
ファイル: CookersModel.cs プロジェクト: neckata/CookingApp
        public async Task <bool> MakeOrder(OrderDTO order)
        {
            ResponseModel model = await _rc.PostDataAsync(PostActionMethods.Order, order);

            return(model.IsSuccessStatusCode);
        }
コード例 #4
0
        public async Task <ObservableCollection <SingleOrderViewModel> > GetOrders()
        {
            var list = new ObservableCollection <SingleOrderViewModel>();

            ResponseModel model = await _rc.PostDataAsync(PostActionMethods.Orders, string.Empty);

            if (model.IsSuccessStatusCode)
            {
                var data = JsonConvert.DeserializeObject <List <OrderDTO> >(model.ResponseContent);
                foreach (var item in data)
                {
                    AddressesDTO address;
                    if (item.AddressID.HasValue)
                    {
                        address = DataBase.Instance.Query <AddressesDTO>().Single(x => x.Id == item.AddressID.Value);
                    }
                    else
                    {
                        address = new AddressesDTO()
                        {
                            AddressName = item.AddressName, City = item.City, Neighborhood = item.Neighborhood, Street = item.Street
                        }
                    };

                    var vm = new SingleOrderViewModel()
                    {
                        ID               = item.ID,
                        AddressID        = item.AddressID,
                        AddressName      = address.AddressName,
                        Address          = string.Format("{0},{1},{2}", address.City, address.Neighborhood, address.Street),
                        City             = address.City,
                        CookerID         = item.CookerID,
                        Neighborhood     = address.Neighborhood,
                        ProductsIncluded = item.ProductsIncluded,
                        Street           = address.Street,
                        CookerName       = item.CookerName,
                        Date             = item.Date,
                        FromTime         = item.FromTime.ToString(),
                        ToTime           = item.ToTime.ToString(),
                        Rating           = item.Rating.HasValue ? item.Rating.Value : 0,
                        Status           = item.Status
                    };

                    if (vm.Status == OrdersEnum.Accepted)
                    {
                        vm.OrderColor      = Color.LightGreen;
                        vm.IsRatingVisible = item.Date < DateTime.Now ? item.Rating.HasValue : false;
                        vm.IsRatеVisible   = item.Date < DateTime.Now ? !item.Rating.HasValue : false;
                    }
                    else if (vm.Status == OrdersEnum.Rejected)
                    {
                        vm.OrderColor = Color.Red;
                    }
                    else if (vm.Status == OrdersEnum.Waiting)
                    {
                        vm.OrderColor = Color.Yellow;
                    }

                    list.Add(vm);
                }
            }

            return(list);
        }