public ActionResult <CarWashVisitDataModel> GetDetails()
        {
            CarWashVisitDatabase  carWashVisitDatabase  = new CarWashVisitDatabase(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CarWashVisit_DatabaseNew.db3"));
            CarWashVisitDataModel carWashVisitDataModel = new CarWashVisitDataModel();

            carWashVisitDataModel.Code                = 200;
            carWashVisitDataModel.Message             = "successfully exicuted";
            carWashVisitDataModel.Success             = true;
            carWashVisitDataModel.CarwashVisitDetails = new ObservableCollection <CarwashVisitDetails>();

            ObservableCollection <Models.CarwashVisitDetails> ListOfCarwashVisitDetails = carWashVisitDatabase.GetCarwashVisitDetailsAsync();

            foreach (var item in ListOfCarwashVisitDetails)
            {
                CarwashVisitDetails carwashVisitDetails = ClassConverter.CastCarwashVisitDetails <CarwashVisitDetails>(item);
                //carwashVisitDetails.Tasks = new ObservableCollection<TaskDetails>();
                ObservableCollection <Models.TaskDetails> ListOfCarwashTaskDetails = carWashVisitDatabase.GetTaskDetailsAsync();
                foreach (var taskDetails in ListOfCarwashTaskDetails)
                {
                    TaskDetails carwashTaskDetails = ClassConverter.CastTaskDetails <TaskDetails>(taskDetails);
                    if (item.VisitId.ToString() == taskDetails.VisitTaskId)
                    {
                        carwashVisitDetails.Tasks.Add(carwashTaskDetails);
                    }
                }

                carWashVisitDataModel.CarwashVisitDetails.Add(carwashVisitDetails);
            }

            return(carWashVisitDataModel);
        }
Ejemplo n.º 2
0
        private void GenerateDataBase()
        {
            string fileName = "XF-Test-Json";

            string   filePath = Path.GetFullPath(fileName);
            FileInfo fileInfo = new FileInfo(fileName);


            string path       = Path.Combine(Environment.CurrentDirectory, @"JsonFile/XF-Test-Json");
            string JSONstring = File.ReadAllText(path);



            CarWashVisitDataModel carwashVisitDetails = JsonConvert.DeserializeObject <CarWashVisitDataModel>(JSONstring, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            GenrateDatabase(carwashVisitDetails);
        }
Ejemplo n.º 3
0
        private async void GenrateDatabase(CarWashVisitDataModel carwashvisit)
        {
            try
            {
                foreach (var carwashVisitDetails in carwashvisit.CarwashVisitDetails)
                {
                    Models.CarwashVisitDetails carwashVisit = new Models.CarwashVisitDetails
                    {
                        VisitId               = carwashVisitDetails.VisitId,
                        HomeBobEmployeeId     = carwashVisitDetails.VisitId,
                        HouseOwnerId          = carwashVisitDetails.VisitId,
                        IsBlocked             = carwashVisitDetails.IsBlocked,
                        StartTimeUtc          = carwashVisitDetails.StartTimeUtc,
                        EndTimeUtc            = carwashVisitDetails.EndTimeUtc,
                        Title                 = carwashVisitDetails.Title,
                        IsReviewed            = carwashVisitDetails.IsReviewed,
                        IsFirstVisit          = carwashVisitDetails.IsFirstVisit,
                        IsManual              = carwashVisitDetails.IsManual,
                        VisitTimeUsed         = carwashVisitDetails.VisitTimeUsed,
                        RememberToday         = carwashVisitDetails.RememberToday,
                        HouseOwnerFirstName   = carwashVisitDetails.HouseOwnerFirstName,
                        HouseOwnerLastName    = carwashVisitDetails.HouseOwnerLastName,
                        HouseOwnerMobilePhone = carwashVisitDetails.HouseOwnerMobilePhone,
                        HouseOwnerAddress     = carwashVisitDetails.HouseOwnerAddress,
                        HouseOwnerZip         = carwashVisitDetails.HouseOwnerZip,
                        HouseOwnerCity        = carwashVisitDetails.HouseOwnerCity,
                        HouseOwnerLatitude    = carwashVisitDetails.HouseOwnerLatitude,
                        HouseOwnerLongitude   = carwashVisitDetails.HouseOwnerLongitude,
                        IsSubscriber          = carwashVisitDetails.IsSubscriber,
                        RememberAlways        = carwashVisitDetails.RememberAlways,
                        Professional          = carwashVisitDetails.Professional,
                        VisitState            = carwashVisitDetails.VisitState,
                        StateOrder            = carwashVisitDetails.StateOrder,
                        ExpectedTime          = carwashVisitDetails.ExpectedTime,
                    };
                    int IsExists = Database.CheckIsExists(carwashVisit);// .Table<CarwashVisitDetails>().Where(array => array.VisitId == taskDetails.TaskId).CountAsync().Result;
                    if (IsExists == 0)
                    {
                        await Database.SaveCarWashDetailsAsync(carwashVisit);

                        foreach (var item in carwashVisitDetails.Tasks)
                        {
                            await Database.SaveTaskDetailsAsync(new Models.TaskDetails
                            {
                                VisitTaskId       = carwashVisitDetails.VisitId.ToString(),
                                TaskId            = item.TaskId,
                                Title             = item.Title,
                                TimesInMinutes    = item.TimesInMinutes,
                                IsTemplate        = item.IsTemplate,
                                Price             = item.Price,
                                PaymentTypeId     = item.PaymentTypeId,
                                PaymentTypes      = item.PaymentTypes,
                                CreateDateUtc     = item.CreateDateUtc,
                                LastUpdateDateUtc = item.LastUpdateDateUtc
                            });
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }