Пример #1
0
        //[ValidateAntiForgeryToken]
        public IActionResult Create(string memberId, string movieId, DateTime startDate, DateTime endDate)
        {
            ObjectId memberOId = new ObjectId(memberId);
            ObjectId movieOId  = new ObjectId(movieId);

            Movie movie = MovieRepository.GetMovieById(movieOId);

            Loan loan            = CreateLoan(memberOId, movie.Id, startDate, endDate);
            int  copiesRemaining = CheckLoansToCopies.Movie(movie.Id, movie.NumberOfCopies, startDate, endDate);

            if (copiesRemaining > 0)
            {
                MovieLoanRepository.InsertMovie(loan);
                return(Redirect("/MovieLoan"));
            }
            else if (copiesRemaining <= 0)
            {
                SerilogMVC(movie);
                string         errorMessage   = "No availiable copies at that date. Please try an other one";
                MovieLoanModel movieLoanModel = new MovieLoanModel();
                movieLoanModel.ErrorMessage = errorMessage;
                return(View(movieLoanModel));
            }
            return(Redirect("/MovieLoan"));
        }
Пример #2
0
        private static void LoanProcessAvailableMovies(Member member, Movie movie, DateTime startDate, DateTime endDate)
        {
            Loan loan = Factory.CreateLoan(startDate, endDate, member);

            loan.MovieArticle = movie;
            MovieLoanRepository.InsertMovie(loan);
            StandardMessages.LoanComplete(movie.Name, loan.EndDate);
        }