protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);

            IConfiguration configuration = new BasicConfiguration();
            var container = configuration.Container;

            _ingredientRepository = new IngredientRepository(GetNewDataContext());
            _semaphoreRepository = new Repository<Semaphore>(GetNewDataContext());
            _mentorRepository = new Repository<Mentor>(GetNewDataContext());

            _ingredientAdviceRepository = new Repository<IngredientAdvice>(GetNewDataContext());
            _ingredientAdviceDomainService = new IngredientAdviceDomainService(_ingredientRepository,
                                                                               _ingredientAdviceRepository,
                                                                               GetNewDataContext());

           

            _mentor = MentorBuilder.BuildMentor();
            _mentorRepository.Add(_mentor);
            _mentorRepository.Persist();

            _redSemaphore = SemaphoreBuilder.BuildRedSemaphore();
            _semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = SemaphoreBuilder.BuildGreenSemaphore();
            _semaphoreRepository.Add(_greenSemaphore);
            _semaphoreRepository.Persist();

            _ingredient = IngredientBuilder.BuildIngredient();
            _ingredientRepository.Add(_ingredient);
            _ingredientRepository.Persist();

            base.Before_each_spec();
        }
        public Mentor UpdateMentor(Mentor updatedMentor)
        {
            var mentorToUpdate = _mentorRepository.FindOne(x => x.Id == updatedMentor.Id);
            mentorToUpdate.CopyStringProperties(updatedMentor);
            
            _mentorRepository.Persist();

            return mentorToUpdate;
        }
        public CertificationMark CreateCertificationMark(Mentor certifier, CertificationMark certificationMarkToCreate)
        {
            var newCertificationMark = new CertificationMark();
            newCertificationMark.CopyStringProperties(certificationMarkToCreate);
            SetCertifier(newCertificationMark, certifier);

            _certificationMarkRepository.Add(newCertificationMark);
            _certificationMarkRepository.Persist();

            return newCertificationMark;
        }
Example #4
0
 public ActionResult EditAdvisor(Mentor updatedAdvisor)
 {
     try
     {
         _mentorDomainService.UpdateMentor(updatedAdvisor);
     }
     catch (Exception)
     {
         return RedirectToAction("EditAdvisor");
     }
     return RedirectToAction("Index");
 }
Example #5
0
        public ActionResult CreateAdvisor(Mentor newAdvisor)
        {
            try
            {
                _mentorDomainService.CreateNewMentor(newAdvisor.MentorName);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
 public static CertificationMark BuildCertificationMark(Mentor mentor)
 {
     var certificationMark = new CertificationMark
     {
         CertificationMarkImageUrlLarge = "",
         CertificationMarkImageUrlMedium = "",
         CertificationMarkImageUrlSmall = "",
         Gs1Code = "",
         CertificationName = "Krav",
         Certifier = mentor
     };
     return certificationMark;
 }
        public Mentor CreateNewMentor(string mentorName)
        {
            if(_mentorRepository.Find(m => m.MentorName == mentorName).FirstOrDefault() != null)
            {
                throw new ApplicationException(String.Format("Mentor with name {0} already exists!", mentorName));
            }

            var mentor = new Mentor {MentorName = mentorName};

            _mentorRepository.Add(mentor);
            _mentorRepository.Persist();

            return mentor;
        }
Example #8
0
 public ProductAdvice BuildProductAdvice(Mentor mentor, Semaphore semaphore)
 {
     var productAdvice = new ProductAdvice()
                            {
                                Advice = "Sveriges Konsumenter anmälde Coca Cola för vilseledande GDA-märkning av sina Coca Cola-flaskor. Att en flaska om 500 ml skulle utgöra två portioner framstår som vilseledande, likaså det faktum att företaget använder två olika portionsstorlekar när det beräknar GDA.",
                                Introduction = "Coca Cola anmält för vilseledande GDA-märkning av dryckesflaskor.",
                                KeyWords = "Coca-Cola, Mer",
                                Label = "Svenska nyheter",
                                Mentor = mentor,
                                Semaphore = semaphore,
                                Published = true,
                                PublishDate = DateTime.Now
                            };
     return productAdvice;
 }
        public ShopgunMembershipUser(string providername,
                                  string username,
                                  object providerUserKey,
                                  string email,
                                  string passwordQuestion,
                                  string comment,
                                  bool isApproved,
                                  bool isLockedOut,
                                  DateTime creationDate,
                                  DateTime lastLoginDate,
                                  DateTime lastActivityDate,
                                  DateTime lastPasswordChangedDate,
                                  DateTime lastLockedOutDate,
                                  int userId,
                                  string displayName,
                                  string password,
                                  string firstName,
                                  string lastName,
                                  Mentor mentor) :
            base(providername,
                                       username,
                                       providerUserKey,
                                       email,
                                       passwordQuestion,
                                       comment,
                                       isApproved,
                                       isLockedOut,
                                       creationDate,
                                       lastLoginDate,
                                       lastActivityDate,
                                       lastPasswordChangedDate,
                                       lastLockedOutDate)
        {

            UserId = userId;
            DisplayName = displayName;
            Password = password;
            FirstName = firstName;
            LastName = lastName;
            Mentor = mentor;

        }
        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof (Base).Assembly);

            RepositoryFactory = CreateStub<RepositoryFactory<IAdviceRepository, AdviceBase>>();

            _adviceApplicationService = new AdviceApplicationService(null, null);

            var mentorRepository = RepositoryFactory.Build<IRepository<Mentor>, Mentor>();

            _mentor = new Mentor
                          {
                              MentorName = "Consumentor"
                          };
            mentorRepository.Add(_mentor);
            mentorRepository.Persist();


            var semaphoreRepository = RepositoryFactory.Build<IRepository<Semaphore>, Semaphore>();

            _redSemaphore = new Semaphore
                                {
                                    ColorName = "Red",
                                    Value = -1
                                };
            semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = new Semaphore
                                  {
                                      ColorName = "Green",
                                      Value = 1
                                  };
            semaphoreRepository.Add(_greenSemaphore);
            semaphoreRepository.Persist();


            var productRepository = RepositoryFactory.Build<IRepository<Product>, Product>();

            _product = ProductBuilder.BuildProduct();
            productRepository.Add(_product);
            productRepository.Persist();

        }
        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);
            _productBuilder = new ProductBuilder();

            _productAdviceRepository = new Repository<ProductAdvice>(GetNewDataContext());
            _productAdviceDomainService =
                new ProductAdviceDomainService(new ProductRepository(GetNewDataContext()),
                                                   _productAdviceRepository, GetNewDataContext());

            _productRepository = new ProductRepository(GetNewDataContext());
            _semaphoreRepository = new Repository<Semaphore>(GetNewDataContext());
            _mentorRepository = new Repository<Mentor>(GetNewDataContext());     

            _mentor = new Mentor
                          {
                MentorName = "Consumentor"
            };
            _mentorRepository.Add(_mentor);
            _mentorRepository.Persist();

            _redSemaphore = new Semaphore
                             {
                ColorName = "Red",
                Value = -1
            };
            _semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = new Semaphore
                                  {
                                      ColorName = "Green",
                                      Value = 1
                                  };
            _semaphoreRepository.Add(_greenSemaphore);
            _semaphoreRepository.Persist();

            _product = ProductBuilder.BuildProduct();
            _productRepository.Add(_product);
            _productRepository.Persist();

            base.Before_each_spec();
        }
Example #12
0
        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);

            _ingredientAdviceRepository = new Repository<IngredientAdvice>(GetNewDataContext());

            _ingredientRepository = new IngredientRepository(GetNewDataContext());
            _semaphoreRepository = new Repository<Semaphore>(GetNewDataContext());
            _mentorRepository = new Repository<Mentor>(GetNewDataContext());

            _mentor = MentorBuilder.BuildMentor();
            _mentorRepository.Add(_mentor);
            _mentorRepository.Persist();

            _redSemaphore = SemaphoreBuilder.BuildRedSemaphore();
            _semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = SemaphoreBuilder.BuildGreenSemaphore();
            _semaphoreRepository.Add(_greenSemaphore);
            _semaphoreRepository.Persist();

            base.Before_each_spec();
        }
        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);

            _productRepository = new ProductRepository(GetNewDataContext());
            _productApplicationService = new ProductApplicationService(null, null, null, null, null);

            _brand = BrandBuilder.BuildBrand();
            using (var brandRepository = new Repository<Brand>(GetNewDataContext()))
            {
                brandRepository.Add(_brand);
                brandRepository.Persist();
            }

            _country = CountryBuilder.BuildCountry();
            using (var countryRepository = new Repository<Country>(GetNewDataContext()))
            {
                countryRepository.Add(_country);
                countryRepository.Persist();
            }

            _mentor = MentorBuilder.BuildMentor();
            _certificationMark = CertificationMarkBuilder.BuildCertificationMark(_mentor);
            using (var certificationMarkRepository = new Repository<CertificationMark>(GetNewDataContext()))
            {
                certificationMarkRepository.Add(_certificationMark);
                certificationMarkRepository.Persist();
            }

            _ingredient = IngredientBuilder.BuildIngredient();
            using (var ingredientRepository = new Repository<Ingredient>(GetNewDataContext()))
            {
                ingredientRepository.Add(_ingredient);
                ingredientRepository.Persist();
            }
        }
        public IList<Ingredient> GetIngredientsWithAdvicesByMentor(Mentor mentor)
        {
            var result = _ingredientRepository.Find(i => i.IngredientAdvices.Any(a => a.Mentor == mentor)).ToList();

            foreach (var ingredient in result)
            {
                var advicesFromMentor = from a in ingredient.IngredientAdvices
                                        where a.Mentor.Id == mentor.Id
                                        orderby a.Id descending
                                        select a;
                ingredient.IngredientAdvices = advicesFromMentor.ToList();
            }

            return result;
        }
Example #15
0
 public void DeleteMentor(Mentor mentorToDelete)
 {
     _mentorRepository.Delete(mentorToDelete);
     _mentorRepository.MergePersist();
 }
 public IList<CertificationMark> GetCertificationMarksByCertifier(Mentor mentor)
 {
     var certificationMarks = _certificationMarkRepository.Find(x => x.MentorId == mentor.Id);
     return certificationMarks.ToList();
 }
 private void SetCertifier(CertificationMark newCertificationMark, Mentor certifier)
 {
     var certififer = _certificationMarkRepository.FindDomainObject(certifier);
     newCertificationMark.Certifier = certififer;
 }