public ActionResult AddClothes(Clothes newClothes) { ClothesRepository clothesRepo = new ClothesRepository(); clothesRepo.CreateClothes(new Clothes { ClothesType = newClothes.ClothesType, AdditionnalNote = newClothes.AdditionnalNote, Color = newClothes.Color, Image = newClothes.Image }); return(Content("Success :)")); }
public ActionResult Clothes() { List <ClothesModel> clothesModel = new List <ClothesModel>(); ClothesRepository clothesRepo = new ClothesRepository(); ColorRepository colorRepo = new ColorRepository(); ClothesTypeRepository clothesTypeRepo = new ClothesTypeRepository(); var allCLothes = clothesRepo.GetAllClothes(); foreach (var clothe in allCLothes.OrderBy(c => c.ClothesType)) { clothesModel.Add(new ClothesModel { Id = clothe.Id, AdditionnalNote = clothe.AdditionnalNote == null ? "N/A" : clothe.AdditionnalNote, ClothesType = clothesTypeRepo.GetAllClothingTypes().Where(t => t.Id == clothe.ClothesType).SingleOrDefault().Name, Color = colorRepo.GetAllColors().Where(c => c.Id == clothe.Color).SingleOrDefault().Name, Image = clothe.Image == null ? "" : clothe.Image }); } return(Json(clothesModel, JsonRequestBehavior.AllowGet)); }
public ClothesService(ClothesRepository clothesRepository) { this.clothesRepository = clothesRepository; }