コード例 #1
0
ファイル: HomeController.cs プロジェクト: clabanow/FutureCodr
        //creates a text string out of bootcamp's locations to be 
        //displayed on home page (i.e. 3 locations would be converted
        //to "<Location 1> + 2 others"
        public Bootcamp ConvertBootcampFormat(Bootcamp bootcamp)
        {
            var bootcamp2 = new Bootcamp
            {
                BootcampId = bootcamp.BootcampID,
                Name = bootcamp.Name,
                LogoLinkUrl = bootcamp.LogoLink
            };

            int locationsCount = _bootcampLocationsRepo.GetAllBootcampLocationsByBootcampId(bootcamp.BootcampID).Count;
            string str = "";
            if (locationsCount > 1)
            {
                if (locationsCount == 2)
                {
                    str = " + 1 other";
                }
                else
                {
                    str = " + " + ((locationsCount - 1)).ToString() + " others";
                }
            }
            var locationById = _locationRepo.GetLocationById(bootcamp.LocationID);
            bootcamp2.Location = locationById.City + ", " + locationById.Country + str;
            return bootcamp2;
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: clabanow/FutureCodr
        //creates a text string out of bootcamp's locations to be
        //displayed on home page (i.e. 3 locations would be converted
        //to "<Location 1> + 2 others"
        public Bootcamp ConvertBootcampFormat(Bootcamp bootcamp)
        {
            var bootcamp2 = new Bootcamp
            {
                BootcampId = bootcamp.BootcampID,
                Name = bootcamp.Name,
                LogoLinkUrl = bootcamp.LogoLink
            };

            int locationsCount = _bootcampLocationsRepo.GetAllBootcampLocationsByBootcampId(bootcamp.BootcampID).Count;
            string str = "";
            if (locationsCount > 1)
            {
                if (locationsCount == 2)
                {
                    str = " + 1 other";
                }
                else
                {
                    str = " + " + ((locationsCount - 1)).ToString() + " others";
                }
            }
            var locationById = _locationRepo.GetLocationById(bootcamp.LocationID);
            bootcamp2.Location = locationById.City + ", " + locationById.Country + str;
            return bootcamp2;
        }
コード例 #3
0
 public void EditBootcamp(Bootcamp bootcamp)
 {
     using (SqlConnection connection = new SqlConnection(Settings.GetConnectionString()))
     {
         DynamicParameters param = AddBootcampParameters(bootcamp);
         param.Add("@BootcampID", bootcamp.BootcampID);
         connection.Execute("BootcampsEdit", param, commandType: CommandType.StoredProcedure);
     }
 }
コード例 #4
0
 public HttpResponseMessage Post(Bootcamp bootcamp)
 {
     if (base.ModelState.IsValid)
     {
         _bootcampRepo.AddBootcamp(bootcamp);
         return(new HttpResponseMessage(HttpStatusCode.OK));
     }
     return(base.Request.CreateErrorResponse(HttpStatusCode.BadRequest, base.ModelState));
 }
コード例 #5
0
 public Bootcamp AddBootcamp(Bootcamp bootcamp)
 {
     using (SqlConnection connection = new SqlConnection(Settings.GetConnectionString()))
     {
         DynamicParameters param = AddBootcampParameters(bootcamp);
         param.Add("@BootcampID", dbType: DbType.Int32, direction: ParameterDirection.Output);
         connection.Execute("BootcampsAdd", param, commandType: CommandType.StoredProcedure);
         bootcamp.BootcampID = param.Get <int>("@BootcampID");
     }
     return(bootcamp);
 }
コード例 #6
0
        public DynamicParameters AddBootcampParameters(Bootcamp bootcamp)
        {
            DynamicParameters parameters = new DynamicParameters();

            parameters.Add("@Name", bootcamp.Name);
            parameters.Add("@PrimaryTechnologyID", bootcamp.PrimaryTechnologyID);
            parameters.Add("@LocationID", bootcamp.LocationID);
            parameters.Add("@Price", bootcamp.Price);
            parameters.Add("@LengthInWeeks", bootcamp.LengthInWeeks);
            parameters.Add("@Website", bootcamp.Website);
            parameters.Add("@LogoLink", bootcamp.LogoLink);
            return(parameters);
        }
コード例 #7
0
        //get specific bootcamp for editing
        public BootcampEditAng Get(int id)
        {
            Bootcamp bootcampByID = _bootcampRepo.GetBootcampByID(id);

            return(new BootcampEditAng
            {
                Name = bootcampByID.Name,
                Price = bootcampByID.Price,
                LengthInWeeks = bootcampByID.LengthInWeeks,
                Website = bootcampByID.Website,
                LogoLink = bootcampByID.LogoLink,
                LocationID = bootcampByID.LocationID,
                PrimaryTechnologyID = bootcampByID.PrimaryTechnologyID,
                BootcampID = bootcampByID.BootcampID
            });
        }
コード例 #8
0
        public IActionResult Register([FromBody] RegisterModel request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var registration = new Bootcamp {
                firstname  = request.firstname,
                lastname   = request.lastname,
                address1   = request.address1,
                address2   = request.address2,
                city       = request.city,
                state      = request.state,
                postalcode = request.postalcode,
                country    = request.country,
                email      = request.email,
                phone      = request.phone,
                member     = request.member == "yes",
                camps      = request.camps,
                submitted  = DateTime.Now,
                paid       = DateTime.Now,
                coupon     = request.coupon,
                badgename  = request.badgename,
                cleared    = DateTime.Now,
                created    = DateTime.Now,
                modified   = DateTime.Now
            };

            (var subtotal, var total) = Calculate(new TotalRequest {
                member = registration.member,
                coupon = registration.coupon,
                camps  = registration.camps
            });

            registration.subtotal = subtotal;
            registration.total    = total;

            _db.Bootcamps.Add(registration);
            _db.SaveChanges();

            return(Json(true));
        }
コード例 #9
0
        public MockRepository()
        {
            Site site = new Site
            {
                SiteName    = "Test",
                SiteLogoURL = "TestUrl"
            };

            mockSite = site;
            BootcampLocation location = new BootcampLocation
            {
                BootcampID = 2,
                LocationID = 1
            };

            MockBootcampLocation = location;
            Location location2 = new Location
            {
                LocationID = 1,
                City       = "Houston",
                Country    = "USA"
            };

            mockLocation = location2;
            Technology technology = new Technology
            {
                Name = "Javascript"
            };

            mockTechnology = technology;
            BootcampTechnology technology2 = new BootcampTechnology
            {
                BootcampID   = 1,
                TechnologyID = 1
            };

            mockBootcampTechnology = technology2;
            ContactForm form = new ContactForm
            {
                ContactFormID = 1,
                Email         = "*****@*****.**",
                Message       = "hello there",
                Name          = "Charles"
            };

            MockContactForm = form;
            Bootcamp bootcamp = new Bootcamp
            {
                BootcampID          = 1,
                PrimaryTechnologyID = 1,
                Name          = "App Academy",
                LocationID    = 2,
                Price         = 0x2ee0,
                LengthInWeeks = 10,
                Website       = "http://www.appacademy.com",
                LogoLink      = "http://sample.com"
            };

            mockBootcamp = bootcamp;
            BootcampSession session = new BootcampSession
            {
                BootcampSessionID = 3,
                BootcampID        = 1,
                LocationID        = 1,
                TechnologyID      = 1,
                StartDate         = new DateTime(0x7de, 8, 1),
                EndDate           = new DateTime(0x7de, 10, 0x16)
            };

            mockBootcampSession = session;
            Link link = new Link
            {
                LinkID     = 1,
                URL        = "http://www.wsj.com",
                LinkText   = "Bootcamps in the WSJ",
                SiteID     = 1,
                Date       = new DateTime(0x7de, 2, 0x16),
                BootcampID = 1
            };

            mockLink = link;
            Review review = new Review
            {
                ReviewID   = 1,
                ReviewText = "It was good",
                IsVerified = false,
                BootcampID = 2,
                UserID     = 1
            };

            mockReview = review;
            User user = new User
            {
                UserID   = 1,
                Email    = "*****@*****.**",
                Password = "******"
            };

            mockUser = user;
        }
コード例 #10
0
 protected override void OnStart(string[] args)
 {
     bootcamp = new Bootcamp(args[0], args[1]);
 }