// GET: /<controller>/
 public RentPointController(IQueryBuilder queryBuilder, ICommandBuilder commandBuilder)
 {
     _queryBuilder   = queryBuilder;
     _commandBuilder = commandBuilder;
     if (!_queryBuilder.For <IEnumerable <RentPoint> >().With(new EmptyCriterion()).Any())
     {
         AddEmployeeCommandContext employeeContext = new AddEmployeeCommandContext()
         {
             Surname    = "Ivanov",
             FirstName  = "Ivan",
             Patronymic = "Ivanovich"
         };
         _commandBuilder.Execute(employeeContext);
         AddRentPointCommandContext komprosRentPointContext = new AddRentPointCommandContext()
         {
             Name     = "Компрос",
             Employee = employeeContext.CreatedEmployee,
             Money    = 10000
         };
         _commandBuilder.Execute(komprosRentPointContext);
         AddRentPointCommandContext leninaRentPointContext = new AddRentPointCommandContext()
         {
             Name     = "Ленина",
             Employee = employeeContext.CreatedEmployee,
             Money    = 10000
         };
         _commandBuilder.Execute(leninaRentPointContext);
         _commandBuilder.Execute(new AddBikeCommandContext()
         {
             Name      = "Kama",
             Cost      = 1000,
             HourCost  = 100,
             RentPoint = komprosRentPointContext.CreatedRentPoint
         });
         _commandBuilder.Execute(new AddBikeCommandContext()
         {
             Name      = "Stels",
             Cost      = 1000,
             HourCost  = 100,
             RentPoint = komprosRentPointContext.CreatedRentPoint
         });
         _commandBuilder.Execute(new AddBikeCommandContext()
         {
             Name      = "Forward",
             Cost      = 1000,
             HourCost  = 100,
             RentPoint = komprosRentPointContext.CreatedRentPoint
         });
         _commandBuilder.Execute(new AddBikeCommandContext()
         {
             Name      = "Lexus134",
             Cost      = 1000,
             HourCost  = 100,
             RentPoint = leninaRentPointContext.CreatedRentPoint
         });
     }
 }
Example #2
0
        public Employee CreateEmployee(string surname, string firstname, string patronymic)
        {
            AddEmployeeCommandContext context = new AddEmployeeCommandContext()
            {
                FirstName  = firstname,
                Surname    = surname,
                Patronymic = patronymic
            };

            _commandBuilder.Execute(context);
            return(context.CreatedEmployee);
        }
        public IActionResult Add(string name, string surname, string firstname, string patronymic, decimal money)
        {
            AddEmployeeCommandContext employeeCommandContext = new AddEmployeeCommandContext()
            {
                Surname    = surname,
                FirstName  = firstname,
                Patronymic = patronymic
            };

            _commandBuilder.Execute(employeeCommandContext);
            _commandBuilder.Execute(new AddRentPointCommandContext()
            {
                Name     = name,
                Employee = employeeCommandContext.CreatedEmployee,
                Money    = money
            });
            ViewBag.Message = string.Format("Точка проката {0} успешно добавлена", name);
            return(View());
        }