Ejemplo n.º 1
0
        public Response <RentDetail> ReturnCarToCompany(int RentID, int KmInfo, int Score)
        {
            Response <RentDetail> res = new Response <RentDetail>();

            // check if the score in 1-5 range and km info is valid
            if (RentDetailValidation.ValidateTheScore(Score) && RentDetailValidation.ValiteKmInfo(KmInfo, RentID))
            {
                try
                {
                    using (var repo = new RentDetailRepository())
                    {
                        res.isSuccess = repo.ReturnCarToCompany(RentID, KmInfo, Score);
                        if (res.isSuccess)
                        {
                            res.Message = "Araç başarıyla firmaya geri döndürüldü";
                        }
                        else
                        {
                            res.Message = "Araç firmaya geri döndürülürken bir aksilik meydana geldi";
                        }
                    }
                    return(res);
                }
                catch (Exception ex)
                {
                    throw new Exception("An error occured in ReturnCarToCompany() func. in SpiceApp.BusinessLayer.RentDetailBusiness", ex);
                }
            }
            else
            {
                res.isSuccess = false;
                res.Message   = "Geçersiz parametreler";
            }
            return(res);
        }
Ejemplo n.º 2
0
        public Response <RentDetail> FetchOneById(int id)
        {
            Response <RentDetail> res = new Response <RentDetail>();

            try
            {
                using (var rentDetailRepo = new RentDetailRepository())
                {
                    res.Data = new List <RentDetail>();
                    RentDetail temp = rentDetailRepo.FetchById(id);
                    if (temp != null)
                    {
                        res.Data.Add(temp);
                        res.isSuccess = true;
                        res.Message   = "Kira detay bilgisi gösteriliyor";
                    }
                    else
                    {
                        res.isSuccess = false;
                        res.Message   = "Kira detay bilgisi gösterilirken bir sorun ile karşılaşıldı";
                    }
                }
                return(res);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured in FetchOneById() function in SpiceApp.BusinessLayer.RentDetailBusiness", ex);
            }
        }
Ejemplo n.º 3
0
        public Response <RentDetail> CompleteReservation(int id)
        {
            // this function only will be called by the employee.
            Response <RentDetail> res = new Response <RentDetail>();

            try
            {
                using (var repo = new RentDetailRepository())
                {
                    res.isSuccess = repo.Insert(new RentDetail()
                    {
                        RentID = id
                    });
                    if (res.isSuccess)
                    {
                        res.Message = "Rezervasyon başarıyla tamamlandı ve araba teslim edildi";
                    }
                    else
                    {
                        res.Message = "Rezervasyon tamamlanırken bir hata oluştu";
                    }
                }
                return(res);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured in CompleteReservation() func. in SpiceApp.BusinessLayer.ReservationBusiness", ex);
            }
        }
Ejemplo n.º 4
0
 public static bool ValiteKmInfo(int KmInfo, int RentID)
 {
     //needs to be more than it was.
     using (var rentRepo = new RentDetailRepository())
     {
         return(rentRepo.FetchById(RentID).Car.KmInfo < KmInfo);
     }
 }
Ejemplo n.º 5
0
        public Response <RentDetail> FetchAllRentDetailById(int id)
        {
            Response <RentDetail> res = new Response <RentDetail>();

            try
            {
                using (var repo = new RentDetailRepository())
                {
                    res.Data      = repo.FetchAllRentDetail(id);
                    res.isSuccess = true;
                    res.Message   = "Kira detayları listelendi";
                }
                return(res);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured in FetchAllRentDetailById() function in SpiceApp.BusinessLayer.RentDetailBusiness", ex);
            }
        }