Ejemplo n.º 1
0
 public int Delete(long id)
 {
     return(genericRepo.Delete(id));
 }
        //Delete a product
        public void DeleteServiceRequest(int id)
        {
            var serviceRequest = _repo.Query <ServiceRequest>().Where(p => p.Id == id).FirstOrDefault();

            _repo.Delete(serviceRequest);
        }
 public virtual void Delete(TKey id)
 {
     genericRepo.Delete(id);
 }
Ejemplo n.º 4
0
        public async static Task SyncNow(IGenericRepo <mstr_meal_order_local> orderlocalRepo, IGenericRepo <mstr_meal_time> mealtimeRepo, IPageDialogService pageDialog)
        {
            Library library = new Library();
            //string URL = Library.KEY_http + Library.KEY_SERVER_IP + "/" + Library.KEY_SERVER_LOCATION + "/sodexo.svc";
            var localOrders = orderlocalRepo.QueryTable();

            foreach (var item in localOrders)
            {
                var mealtime = mealtimeRepo.QueryTable().FirstOrDefault(x => x.ID == item.meal_time_id && x.status_id == 1);

                string time = DateTime.Now.ToString("HH:mm");
                //DateTime lateformat= DateTime.ParseExact(late_cut_off, "HH:mm",
                //                                    CultureInfo.InvariantCulture);
                DateTime lateformat = Convert.ToDateTime(mealtime.late_cut_off_start_time, CultureInfo.InvariantCulture);
                DateTime dtFromDate = DateTime.ParseExact(mealtime.cut_off_start_time, "HH:mm", CultureInfo.InvariantCulture);
                DateTime dtToDate   = DateTime.ParseExact(time, "HH:mm", CultureInfo.InvariantCulture);

                var parameterDate = DateTime.ParseExact(item.order_date, "dd/MM/yyyy", CultureInfo.InvariantCulture);

                var todaysDate = DateTime.Today;

                if ((dtToDate > lateformat && DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) == item.order_date) || parameterDate < todaysDate)
                {
                    orderlocalRepo.Delete(item.autoid.ToString());
                }
                else
                {
                    bool Check_order_result = await getfirstorder(item.P_id);

                    if (Check_order_result || Library.KEY_USER_ROLE == "Nurse" || Library.KEY_USER_ROLE == "Nurse+FSA")
                    {
                        await CheckOrder(item.order_date, item.P_id);

                        if (!string.IsNullOrEmpty(rid))// delete it if it is blank
                        {
                            int  id       = Convert.ToInt32(rid);
                            bool response = await Check_Order_Taken(item.order_date, item.P_id, mealtime.meal_name.Trim(), id);

                            if (!response)
                            {
                                item.order_id = id;
                                // Serialize our concrete class into a JSON String
                                var stringPayload = await Task.Run(() => JsonConvert.SerializeObject(item));

                                // Wrap our JSON inside a StringContent which then can be used by the HttpClient class
                                var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");

                                // display a message jason conversion
                                //var message1 = new MessageDialog("Data is converted in json.");
                                //await message1.ShowAsync();

                                using (var httpClient = new System.Net.Http.HttpClient())
                                {
                                    var httpResponse = new System.Net.Http.HttpResponseMessage();
                                    // Do the actual request and await the response


                                    // httpResponse = new Uri(URL + "/" + Library.METHODE_UPDATE_ORDER); //replace your Url
                                    httpResponse = await httpClient.PostAsync(Library.URL + "/" + Library.METHODE_UPDATE_ORDER, httpContent);



                                    // If the response contains content we want to read it!
                                    await CheckOrderReaponse(orderlocalRepo, item, httpResponse, pageDialog);
                                }
                            }
                            else
                            {
                                orderlocalRepo.Delete(item.autoid.ToString());
                            }
                        }
                        else
                        {
                            int id = String.IsNullOrEmpty(rid) ? 0 : Convert.ToInt32(rid);

                            bool response = await Check_Order_Taken(item.order_date, item.P_id, mealtime.meal_name.Trim(), id);

                            if (!response)
                            {
                                var stringPayload = await Task.Run(() => JsonConvert.SerializeObject(item));

                                // Wrap our JSON inside a StringContent which then can be used by the HttpClient class
                                var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");

                                using (var httpClient = new System.Net.Http.HttpClient())
                                {
                                    var httpResponse = new System.Net.Http.HttpResponseMessage();
                                    // Do the actual request and await the response


                                    // httpResponse = new Uri(URL + "/" + Library.METHODE_UPDATE_ORDER); //replace your Url
                                    httpResponse = await httpClient.PostAsync(Library.URL + "/" + Library.METHODE_SAVEORDER, httpContent);


                                    var orderResponse = await CheckOrderReaponse(orderlocalRepo, item, httpResponse, pageDialog);
                                }
                            }
                            else
                            {
                                orderlocalRepo.Delete(item.autoid.ToString());
                            }
                        }
                    }
                }
            }
        }