Пример #1
0
        public async Task UpdateReservationTest()
        {
            var reservation = await _target.GetById(2);

            reservation.Von = new DateTime(2020, 1, 20);
            await _target.Update(reservation);

            var result = await _target.GetById(2);

            Assert.Equal(new DateTime(2020, 1, 20), result.Von);
        }
Пример #2
0
        public override async Task <ReservationDto> GetById(GetReservationByIdRequest request, ServerCallContext context)
        {
            ReservationManager manager     = new ReservationManager();
            Reservation        reservation = await manager.GetById(request.Id);

            ReservationDto result = reservation.ConvertToDto();

            return(result);
        }
        public ReservationDto ReadReservation(int id)
        {
            WriteActualMethod();

            var reservation = _reservationManager.GetById(id);

            if (reservation == null)
            {
                throw new FaultException <AutoReservationFault>(new AutoReservationFault
                {
                    ErrorCode = AutoReservationFault.RequestedEntityDoesNotExist
                });
            }

            return(reservation.ConvertToDto());
        }
 public ReservationDto GetReservation(int id)
 {
     WriteActualMethod();
     return(DtoConverter.ConvertToDto(reservationManager.GetById(id)));
 }
 public ReservationDto GetReservationById(int reservationId)
 {
     WriteActualMethod();
     return(reservationManager.GetById(reservationId).ConvertToDto());
 }
Пример #6
0
        public ActionResult Detail(Rezervasyon reservation)
        {
            var message = "İşleminize devam edemiyoruz. Lütfen giriş yaptığınız değerleri kontrol edip tekrar deneyiniz!";
            var success = false;

            if (ModelState.IsValid)
            {
                //Kiralayan bilgisi yeni ise ekle
                if (reservation.RentUserID == 0)
                {
                    var rentUser = _rentUserManager.List(i => i.Name == reservation.RentUser.Name && i.PhoneNumber == reservation.RentUser.PhoneNumber).FirstOrDefault();
                    if (rentUser == null)
                    {
                        _rentUserManager.Insert(reservation.RentUser);
                        rentUser = reservation.RentUser;
                    }
                    reservation.RentUserID = rentUser.Id;
                }
                else
                {
                    reservation.RentUser = _rentUserManager.GetById(reservation.RentUserID);
                }

                if (reservation.AdminID <= 0)
                {
                    reservation.AdminID = 1; //şimdilik default 1 atıldı
                }

                if (reservation.Id > 0)
                {
                    var persistent = _reservationManager.GetById(reservation.Id);
                    if (persistent != null)
                    {
                        persistent.İadeYeri   = reservation.İadeYeri;
                        persistent.AlisYeri   = reservation.AlisYeri;
                        persistent.IadeTarihi = reservation.IadeTarihi;
                        persistent.AlisTarihi = reservation.AlisTarihi;
                        persistent.CarID      = reservation.CarID;
                        persistent.RentUserID = reservation.RentUserID;
                        persistent.Status     = reservation.Status;
                        persistent.AdminID    = reservation.AdminID;

                        _reservationManager.Update(persistent);
                        message = "Rezervasyon başarıyla güncellendi.";
                        success = true;
                    }
                    else
                    {
                        message = "Rezervasyon bilgileri kaydedilemedi!";
                    }
                }
                else
                {
                    _reservationManager.Insert(reservation);
                    message = "Yeni rezervasyon kaydı başarıyla eklendi.";
                    success = true;
                }
            }

            ViewBag.ReservationResult  = success;
            ViewBag.ReservationMessage = message;
            return(GetModel(reservation));
        }