Exemple #1
0
        public HelperRequest GetKlientZamowien(string nazwisko)
        {
            var helper = new HelperRequest();

            helper.Number = 0;

            var countKlient = _context.Klients.Count(x => x.Nazwisko == nazwisko);

            if (countKlient == 0)
            {
                helper.Number = 1;
                return(helper);
            }


            var countKlientZamowienia = _context.Zamowienies.Count(x => x.Klient.Nazwisko == nazwisko);

            if (countKlientZamowienia == 0)
            {
                helper.Number = 2;
                return(helper);
            }



            //if(_context.Zamowienies.Where(x=> x.Klient.Nazwisko))
            helper.List = _context.Zamowienies.Where(x => x.Klient.Nazwisko == nazwisko).Include(z => z.ZamowienieWyrobCukierniczies).ThenInclude(x => x.WyrobCukierniczy).ToList();
            return(helper);
        }
Exemple #2
0
        public HelperRequest DeleteDoctor(DeleteDoctorRequest request)
        {
            var helper = new HelperRequest();

            var countDoctor = _context.Doctors.Count(doc =>
                                                     doc.LastName == request.LastName && doc.FirstName == request.FirstName);

            if (countDoctor == 0)
            {
                helper.Number = 0;
                return(helper);
            }

            var selectDoctorId = _context.Doctors.Where(doc =>
                                                        doc.LastName == request.LastName && doc.FirstName == request.FirstName).Select(x => x.IdDoctor).ToArray();


            var doctor = new Doctor
            {
                IdDoctor = selectDoctorId[0]
            };

            _context.Attach(doctor);
            _context.Remove(doctor);
            _context.SaveChangesAsync();

            helper.Number = 1;
            return(helper);
        }
Exemple #3
0
        public HelperRequest UpdateDoctor(UpdateDoctorRequest request)
        {
            var helper = new HelperRequest();

            var countDoctor = _context.Doctors.Count(doc =>
                                                     doc.LastName == request.LastName && doc.FirstName == request.FirstName);

            if (countDoctor == 0)
            {
                helper.Number = 0;
                return(helper);
            }

            var doctor = new Doctor
            {
                FirstName = request.FirstName,
                LastName  = request.LastName,
                Email     = request.Email,
            };

            _context.Attach(doctor);
            _context.Entry(doctor).Property("FirstName").IsModified = true;
            _context.Entry(doctor).Property("LastName").IsModified  = true;
            _context.Entry(doctor).Property("Email").IsModified     = true;

            _context.SaveChangesAsync();

            helper.Number = 1;

            return(helper);
        }
        static void Main(string[] args)
        {
            InitLog.logger.Information("started application for update qualify status");
            IOrganizationService orgSvc = HelperRequest.ConnectionCrm();
            List <Entity[]>      reservationContracts = HelperRequest.GetPagingReservationContract(orgSvc);

            ProcessingStatus(orgSvc, reservationContracts);
            InitLog.logger.Information("successful entity update");
        }
Exemple #5
0
        public IActionResult RemoveDoctor(DeleteDoctorRequest request)
        {
            HelperRequest helperRequest = _context.DeleteDoctor(request);

            switch (helperRequest.Number)
            {
            case 0:
                return(BadRequest("Doctor with this Name and Lastname not exist"));

            default:
                return(Ok("Doctor remove"));
            }
        }
Exemple #6
0
        public IActionResult UpdateDoctor(UpdateDoctorRequest updateDoctorRequest)
        {
            HelperRequest helper = _context.UpdateDoctor(updateDoctorRequest);

            switch (helper.Number)
            {
            case 0:
                return(BadRequest("Doctor with this Name and Lastname not exist"));

            default:
                return(Ok("Doctor modify"));
            }
        }
Exemple #7
0
        public IActionResult GetKlient(string nazwisko)
        {
            HelperRequest helperRequest = _context.GetKlientZamowien(nazwisko);


            switch (helperRequest.Number)
            {
            case 1:
                return(BadRequest($"Klient o nazwisku \"{nazwisko}\" nie istnieje"));

            case 2:
                return(BadRequest($"Klient \"{nazwisko}\" nie posiada zamowien"));

            default:
                return(Ok(helperRequest.List));
            }
        }
Exemple #8
0
        public IActionResult CreateZamowienie(AddNewZamowianieRequest request, int id)
        {
            HelperRequest helperRequest = _context.AddNewZamowienie(request, id);


            switch (helperRequest.Number)
            {
            case 1:
                return(BadRequest($"Brak klienta o id: \"{id}\" "));

            case 2:
                return(BadRequest($"Wyrob nie istnieje w bazie danych"));

            default:
                return(Ok("Dodano zamowienie!"));
            }
            ;
        }
Exemple #9
0
        public HelperRequest AddNewZamowienie(AddNewZamowianieRequest request, int id)
        {
            /*
             * int maxIdWyrobuCukierczniego = _context.WyrobCukierniczies.Max(m => m.IdWyrobCukierniczy);
             * int maxIdZamowienia = _context.Zamowienies.Max(m => m.IdZamowienie);
             */

            var helper = new HelperRequest();

            helper.Number = 0;


            var countIdKlienta = _context.Klients.Count(c => c.IdKlient == id);

            if (countIdKlienta == 0)
            {
                helper.Number = 1;
                return(helper);
            }

            WyrobCukierniczy wyrob = null;

            foreach (var wyr in request.Wyroby)
            {
                var countWyrob = _context.WyrobCukierniczies.Count(c => c.Nazwa == wyr.Wyrob);

                if (countWyrob == 0)
                {
                    helper.Number = 2;
                    return(helper);
                }
                else
                {
                    wyrob = new WyrobCukierniczy
                    {
                        Nazwa = wyr.Wyrob
                    };
                }
            }



            var zamowienie = new Zamowienie
            {
                IdKlient      = id,
                DataPrzyjecia = request.DataPrzyjecia,
                Uwagi         = request.Uwagi,
            };

            var zamowienieWyrob = new ZamowienieWyrobCukierniczy
            {
                Uwagi            = request.Uwagi,
                WyrobCukierniczy = wyrob,
                Zamowienie       = zamowienie
            };



            _context.Attach(zamowienie);
            _context.Add(zamowienie);
            _context.SaveChangesAsync();


            return(helper);
        }