コード例 #1
0
        public ActionResult Edit(int id, FormCollection collection, ClubDetailsViewModel model)
        {
            try
            {
                OrganizationProcessor orgProcessor  = new OrganizationProcessor();
                CityProcessor         cityProcessor = new CityProcessor();
                var clubCityID    = Request.Form["gradID"];
                var stadiumCityID = Request.Form["stadiumGradID"];

                Stadium      stadium      = orgProcessor.RetrieveOrganizationStadium(model.id);
                City         clubCity     = cityProcessor.getCity(Int32.Parse(clubCityID));
                City         stadiumCity  = cityProcessor.getCity(Int32.Parse(stadiumCityID));
                Organization organization = orgProcessor.getOrganization(model.id);
                organization.Name = model.name;
                organization.City = clubCity;
                stadium.Name      = model.name;
                stadium.City      = stadiumCity;
                stadium.Capacity  = model.stadium.capacity;
                stadium.Address   = model.stadium.address;

                orgProcessor.StoreOrganizationChanges(organization);
                orgProcessor.StoreStadiumChanges(stadium);

                return(RedirectToAction("Details"));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
コード例 #2
0
        public void Validate_GetOrganisation()
        {
            int id           = 1;
            var organization = new Organization();

            var repository = new Mock <IOrganizationRepository>();

            repository.Setup(x => x.getOrganization(id)).Returns(organization);

            OrganizationProcessor processor = new OrganizationProcessor();

            processor.Repository = (IOrganizationRepository)repository.Object;

            var res = processor.getOrganization(id);

            repository.Verify(x => x.getOrganization(id), Times.Exactly(1));
        }
コード例 #3
0
        public Organization RetrieveOrganization(int id)
        {
            var organizationProcessor = new OrganizationProcessor();

            return(organizationProcessor.getOrganization(id));
        }