private IList <CertificationMark> MapMarkingNames(IEnumerable <string> markingNames) { using ( var certificationMarkRepository = RepositoryFactory.Build <IRepository <CertificationMark>, CertificationMark>()) { IList <CertificationMark> certificationMarks = new List <CertificationMark>(markingNames.Count()); foreach (var markingName in markingNames) { var name = markingName; CertificationMark certificationMark; try { certificationMark = certificationMarkRepository.FindOne(m => m.CertificationName == name); } catch (Exception) { Log.Debug("CertificationMark not found when mapping: {0}", name); certificationMark = new CertificationMark { CertificationName = name }; } certificationMarks.Add(certificationMark); } return(certificationMarks); } }
public CertificationMark UpdateCertificationMark(CertificationMark updatedCertificationMark) { var certificationMarkToUpdate = _certificationMarkRepository.FindOne(x => x.Id == updatedCertificationMark.Id); certificationMarkToUpdate.CopyStringProperties(updatedCertificationMark); _certificationMarkRepository.Persist(); return(certificationMarkToUpdate); }
public CertificationMark CreateCertificationMark(Mentor certifier, CertificationMark certificationMarkToCreate) { var newCertificationMark = new CertificationMark(); newCertificationMark.CopyStringProperties(certificationMarkToCreate); SetCertifier(newCertificationMark, certifier); _certificationMarkRepository.Add(newCertificationMark); _certificationMarkRepository.Persist(); return(newCertificationMark); }
public ActionResult CreateCertificationMark(CertificationMark certificationMarkToCreate) { try { _certificationMarkDomainService.CreateCertificationMark(CurrentMentor, certificationMarkToCreate); return(RedirectToAction("Index")); } catch (Exception exception) { return(View()); } }
public static CertificationMark BuildCertificationMark(Mentor mentor) { var certificationMark = new CertificationMark { CertificationMarkImageUrlLarge = "", CertificationMarkImageUrlMedium = "", CertificationMarkImageUrlSmall = "", Gs1Code = "", CertificationName = "Krav", Certifier = mentor }; return(certificationMark); }
public ActionResult EditCertificationMark(CertificationMark updatedCertificationMark, FormCollection collection) { try { _certificationMarkDomainService.UpdateCertificationMark(updatedCertificationMark); return(RedirectToAction("Index")); } catch { var certificationMark = _certificationMarkDomainService.GetCertificationMarkById(updatedCertificationMark.Id); return(View(certificationMark)); } }
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 override Product Map(ProductGWO source) { var company = MapCompany(source.Supplier); var brand = MapBrand(source.Trademark); if (brand.Owner == null) { brand.Owner = company; } var ingredients = MapTableOfContentsToIngredients(source.Content); var originCountry = MapOriginCountry(source.Origin); IList <AllergyInformation> allergyInformation = new List <AllergyInformation>(); foreach (var allergyInfoGwo in source.Allergies) { var ingredient = MapIngredient(allergyInfoGwo.SubstanceName); allergyInformation.Add(new AllergyInformation { Allergene = ingredient, Remark = allergyInfoGwo.Remark }); } var certificationMarks = new List <CertificationMark>(); using ( var certificationMarkRepository = RepositoryFactory.Build <IRepository <CertificationMark>, CertificationMark>()) { foreach (var markInfoGwo in source.Markings) { var markInfoGwoCopy = markInfoGwo; CertificationMark certificationMark; try { certificationMark = certificationMarkRepository.FindOne(m => m.CertificationName == markInfoGwoCopy.MarkName); } catch (Exception) { certificationMark = new CertificationMark { CertificationName = markInfoGwo.MarkName }; } certificationMarks.Add(certificationMark); } } return(new Product { AllergyInformation = allergyInformation, Brand = brand, Description = "", GlobalTradeItemNumber = source.EAN, //Ingredients = ingredients, //CertificationMarks = certificationMarks, OriginCountry = originCountry, ProductName = source.Name, //Quantity = QuantityUnit = source.WeightVolume, TableOfContent = source.Content, LastUpdated = DateTime.Now, Durability = source.Durability, ImageUrlLarge = source.ImageURL_Jpg300px, ImageUrlMedium = source.ImageURL_Jpg150px, ImageUrlSmall = source.ImageURL_Jpg66px, Nutrition = source.Nutrition, SupplierArticleNumber = source.SuppArtNo }); }
public void DeleteCertificationMark(CertificationMark certificationMarkToDelete) { certificationMarkToDelete = _certificationMarkRepository.FindOne(x => x.Id == certificationMarkToDelete.Id); _certificationMarkRepository.Delete(certificationMarkToDelete); _certificationMarkRepository.Persist(); }
private void SetCertifier(CertificationMark newCertificationMark, Mentor certifier) { var certififer = _certificationMarkRepository.FindDomainObject(certifier); newCertificationMark.Certifier = certififer; }