private async void btnSetSchedule_Click(object sender, EventArgs e)
        {
            var request = new ScheduleUpsertRequest()
            {
                RequestID = _requestID.GetValueOrDefault(),
            };
            var date = new DateTime(dateTimePicker.Value.Year,
                                    dateTimePicker.Value.Month, dateTimePicker.Value.Day, TimePicker.Value.Hour, TimePicker.Value.Minute, TimePicker.Value.Second);

            request.DateofSchedule   = date;
            request.isPaid           = false;
            request.totalPrice       = 0;
            request.ScheduleStatusID = 1;

            var model = await _scheduleService.Insert <Data.Model.Schedule>(request);

            if (model != null)
            {
                MessageBox.Show("Termin servisiranja uspješno evidentiran!", "Zakazivanje termina", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }

            var modelReq = await _requestService.GetById <Data.Model.Request>(_requestID);

            var UpsertReq = new RequestUpsert()
            {
                RequestID       = modelReq.RequestID,
                DateOfRequest   = modelReq.DateOfRequest,
                UserID          = modelReq.UserID,
                CarServiceID    = modelReq.CarServiceID,
                RequestStatusID = 2
            };
            var modelUpdateReq = await _requestService.Update <Data.Model.Request>(_requestID, UpsertReq);
        }
        public Data.Model.Request Update(int id, RequestUpsert request)
        {
            var x = _context.Requests.Include(r => r.User).ThenInclude(r => r.CarModel).Where(r => r.RequestID == id).SingleOrDefault();

            _context.Requests.Attach(x);
            _context.Requests.Update(x);

            x.RequestStatusID = request.RequestStatusID;
            _context.SaveChanges();

            var model = new Data.Model.Request()
            {
                RequestID        = x.RequestID,
                DateOfRequest    = x.DateOfRequest,
                Date             = x.DateOfRequest.Day + "." + x.DateOfRequest.Month + "." + x.DateOfRequest.Year,
                UserID           = x.UserID,
                UserNameLastName = x.User.FirstName + " " + x.User.LastName,
                UserCar          = x.User.CarModel.CarModelName,
                CarServiceID     = x.CarServiceID,
                StatusID         = x.RequestStatusID,
            };
            var ServicesList = _context.requestServices.Include(s => s.Service).Where(s => s.RequestID == x.RequestID).ToList();

            model.ListOfRequestedServices = new List <string>();
            foreach (var s in ServicesList)
            {
                model.ListOfRequestedServices.Add(s.Service.ServiceName);
            }
            return(model);
        }
        private async void btnDecline_Click(object sender, EventArgs e)
        {
            var modelReq = await _requestService.GetById <Data.Model.Request>(_requestID);

            var UpsertReq = new RequestUpsert()
            {
                RequestID       = modelReq.RequestID,
                DateOfRequest   = modelReq.DateOfRequest,
                UserID          = modelReq.UserID,
                CarServiceID    = modelReq.CarServiceID,
                RequestStatusID = 3
            };
            var modelUpdateReq = await _requestService.Update <Data.Model.Request>(_requestID, UpsertReq);

            if (modelUpdateReq != null)
            {
                MessageBox.Show("Odbili ste zahtjev za servisiranje!", "Odbijanje zahtjeva", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }
        public Data.Model.Request Insert(RequestUpsert request)
        {
            var entity = _mapper.Map <Database.Request>(request);

            _context.Requests.Add(entity);
            _context.SaveChanges();
            var x = _context.Requests.Include(r => r.User).ThenInclude(r => r.CarModel).Where(r => r.RequestID == entity.RequestID).SingleOrDefault();

            foreach (var o in request._selectedServicesList)
            {
                _context.requestServices.Add(new Database.RequestServices()
                {
                    RequestID = x.RequestID,
                    ServiceID = o.ServiceID
                });
                _context.SaveChanges();
            }
            var model = new Data.Model.Request()
            {
                RequestID        = x.RequestID,
                DateOfRequest    = x.DateOfRequest,
                Date             = x.DateOfRequest.Day + "." + x.DateOfRequest.Month + "." + x.DateOfRequest.Year,
                UserID           = x.UserID,
                UserNameLastName = x.User.FirstName + " " + x.User.LastName,
                UserCar          = x.User.CarModel.CarModelName,
                CarServiceID     = x.CarServiceID,
                StatusID         = x.RequestStatusID,
            };
            var ServicesList = _context.requestServices.Include(s => s.Service).Where(s => s.RequestID == x.RequestID).ToList();

            model.ListOfRequestedServices = new List <string>();
            foreach (var s in ServicesList)
            {
                model.ListOfRequestedServices.Add(s.Service.ServiceName);
            }
            return(model);
        }
 public Data.Model.Request Insert(RequestUpsert request)
 {
     return(_service.Insert(request));
 }
 public Data.Model.Request Update(int id, RequestUpsert req)
 {
     return(_service.Update(id, req));
 }
示例#7
0
        public async Task SendRequest()
        {
            var requestsList = await _requestByClientService.Get <List <Data.ViewModel.RequestVM> >(null);

            if (requestsList.Count() > 0)
            {
                foreach (var x in requestsList)
                {
                    if (x.UserID == APIService.UserID)
                    {
                        await Application.Current.MainPage.DisplayAlert("Upozorenje", "Imate već jedan aktivan zahtjev za termin servisiranja u nekom od auto servisa. Da bi poslali zahtjev za servisranjem nekom od auto servisa, ne smijete imati trenutno aktivnih zahtjeva(zahtjev koji je na čekanju i nije obrađen).", "OK");

                        return;
                    }
                }
            }
            var userModel = await _userService.GetById <Data.Model.Users>(APIService.UserID);


            ScheduleRequest schReq = new ScheduleRequest()
            {
                userName     = userModel.FirstName,
                userLastName = userModel.LastName
            };

            var schedulesList = await _scheduleService.Get <List <Data.Model.Schedule> >(schReq);

            if (schedulesList.Count() > 0)
            {
                foreach (var x in schedulesList)
                {
                    if (x.ScheduleStatusID == 1)
                    {
                        await Application.Current.MainPage.DisplayAlert("Upozorenje", "Trenutno imate aktivan termin u auto servisu: " + x.CarServiceName + ". Trenutni termin mora biti završen(okončan) da bi mogli poslati novi zahtjev za servisiranjem u ovaj ili neki drugi auto servis!", "OK");

                        return;
                    }
                }
            }
            var request = new RequestUpsert()
            {
                DateOfRequest   = DateTime.Now,
                UserID          = APIService.UserID,
                CarServiceID    = modelCS.CarServiceID,
                RequestStatusID = 1,
            };

            foreach (var x in SelectedServicesList)
            {
                request._selectedServicesList.Add(new Data.Model.Services()
                {
                    ServiceID = x.ServiceID
                });
            }

            var modelReq = await _requestService.Insert <Data.Model.Request>(request);

            if (modelReq != null)
            {
                await Application.Current.MainPage.DisplayAlert("Obrada uspješna.", "Uspješno ste poslali zahtjev za termin servisiranja.", "OK");

                return;
            }
        }