// GET: Bills
        public ActionResult Fatura()
        {
            InvoiceVM Fatura = new InvoiceVM();

            UserDetail rentuser = _userDetailService.FindByUserName(HttpContext.User.Identity.Name);

            Fatura.Kiralayan = rentuser;

            Fatura.Kiralama = _rentService.GetByDefault(x => x.UserDetail.UserName == rentuser.UserName);

            var days = (int)Fatura.Kiralama.EndDate.Subtract(Fatura.Kiralama.StartDate).TotalDays + 1;

            Car rentalcar = _carService.GetById(Fatura.Kiralama.CarID);

            Bill newBill = new Bill();

            newBill.Date   = DateTime.Now;
            newBill.Cost   = days * rentalcar.CostPerDay;
            newBill.UserID = rentuser.Id;
            _billService.Add(newBill);

            Fatura.FaturaInfo   = newBill.Id;
            Fatura.KiralananGun = days;
            Fatura.Ucret        = newBill.Cost;
            Fatura.AracAdi      = rentalcar.CModel;
            return(View(Fatura));
        }
Exemple #2
0
        public HttpResponseMessage Login(Credentials model)
        {
            var url = "";

            if (model.Username == null || model.Password == null)
            {
                url = "http://localhost:58112/Main/Login";
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new { Success = true, RedirectUrl = url }));
            }
            if (_userDetailService.CheckCredentials(model.Username, model.Password))
            {
                UserDetail kullanici = new UserDetail();
                kullanici = _userDetailService.FindByUserName(model.Username);
                if (kullanici.Role == Role.Admin)
                {
                    url = "http://localhost:58112/Admin/Home/Index/" + kullanici.Id;
                    return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true, RedirectUrl = url }));
                }
                else if (kullanici.Role == Role.Member)
                {
                    url = "http://localhost:58112/Main/HomePage/" + kullanici.Id;
                    return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true, RedirectUrl = url }));
                }
                else
                {
                    url = "http://localhost:58112/Main/HomePage";
                    return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true, RedirectUrl = url }));
                }
            }
            url = "http://localhost:58112/Main/Login";
            return(Request.CreateResponse(HttpStatusCode.BadRequest, new { Success = true, RedirectUrl = url }));
        }
Exemple #3
0
        public ActionResult Renting(Rent model)
        {
            model.Billed   = true;
            model.Returned = false;
            model.Paid     = true;
            UserDetail kullanici = _userDetailService.FindByUserName(HttpContext.User.Identity.Name);

            model.UserID = kullanici.Id;
            _rentService.Add(model);
            return(RedirectToAction("Fatura", "Invoice", new { area = "" }));
        }