public ActionResult Accept(Guid businessTripId)
        {
            var businessTripModel = new BusinessTripModel(businessTripId);
            businessTripModel.ChangeStatus(BusinessTripStatus.Accepted);

            return View("StatusChangedSuccessfully");
        }
        public void Add_ElementIsFoundInStorageByHisId()
        {
            businessTripsRepository.Add(businessTripModel);
            businessTripsRepository.SaveChanges();

            var actual = new BusinessTripModel(businessTripsRepository.GetById(businessTripModel.Id));

            Assert.AreEqual(businessTripModel.Id, actual.Id);
        }
 public UserBusinessTripViewModel(BusinessTripModel businessTripModel)
 {
     StartingDate = businessTripModel.StartingDate;
     EndingDate = businessTripModel.EndingDate;
     Id = businessTripModel.Id;
     Location = businessTripModel.ClientLocation;
     Accomodation = businessTripModel.Accomodation;
     Status = businessTripModel.Status;
 }
        public ActionResult GetDetails(Guid businessTripId)
        {
            BusinessTripModel businessTripModel = new BusinessTripModel(businessTripId);

            if (IsOwnBusinessTrip(businessTripModel.User.Id) || User.IsInRole("HR"))
            {
                return View("Details", businessTripModel);
            }

            return RedirectToAction("GetUserBusinessTrips");
        }
        public ActionResult Cancel(Guid businessTripId)
        {
            BusinessTripModel businessTripModel = new BusinessTripModel(businessTripId);

            if (businessTripModel.Status == BusinessTripStatus.Accepted)
            {
                Email userEmail = new Email();
                userEmail.SendCancelBusinessTripEmail(businessTripModel.Id);
            }

            businessTripModel.ChangeStatus(BusinessTripStatus.Canceled);

            return GetUserBusinessTrips();
        }
        public void Accept_BusinessTripIdInStorage_ReturnsStatusChangedSuccessfullyView()
        {
            var businessTripRepository = new BusinessTripsRepository();

            var userRegistrationModel = new UserRegistrationModel();
            userRegistrationModel.Save();

            var businessTripModel = new BusinessTripModel
            {
                User = new UserModel(userRegistrationModel.Id),
                StartingDate = DateTime.Now,
                EndingDate = DateTime.Now
            };

            businessTripRepository.Add(businessTripModel);
            businessTripRepository.SaveChanges();

            var result = controller.Accept(businessTripModel.Id) as ViewResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("StatusChangedSuccessfully", result.ViewName);
        }
        public void Add_ElementsAreFoundInStorageByUser()
        {
            for (int i = 0; i < 10; i++)
            {
                businessTripModel = new BusinessTripModel
                {
                    Id = Guid.NewGuid(),
                    EndingDate = DateTime.Now,
                    StartingDate = DateTime.Now,
                    User = userModel
                };

                businessTripsRepository.Add(businessTripModel);
            }

            businessTripsRepository.SaveChanges();

            var actual = businessTripsRepository.GetByUser(userRegistrationModel.Id).Select(e => new BusinessTripModel(e));

            foreach (var tripModel in actual)
            {
                Assert.AreEqual(userRegistrationModel.Id, tripModel.User.Id);
            }
        }
 public void Add(BusinessTripModel businessTripModel)
 {
     storage.Add(businessTripModel.ToEntity());
 }
        public ActionResult Submit(BusinessTripModel businessTripModel)
        {
            if (!ModelState.IsValid)
            {
                return View("Submit");
            }

            businessTripModel.User = new UserModel(GetUserIdFromCookie());
            businessTripModel.Save();

            var email = new Email();
            email.SendBusinessTripRegistrationEmail(businessTripModel.Id);

            return View("RegisteredSuccessfully");
        }
        public void Initialize()
        {
            EfStorage storage = new EfStorage(new EfStorageDbInitializerTest());
            storage.Database.Initialize(true);

            userRegistrationModel = new UserRegistrationModel()
            {
                Email = "*****@*****.**",
                Password = "******"
            };

            userRegistrationModel.Save();

            userModel = new UserModel(userRegistrationModel.Id);

            businessTripsRepository = new BusinessTripsRepository();

            businessTripModel = new BusinessTripModel
            {
                Id = Guid.NewGuid(),
                EndingDate = DateTime.Now,
                StartingDate = DateTime.Now,
                User = userModel
            };

            businessTripsRepository.SaveChanges();
        }