public static TechniqueModel MapTechniqueModel(Gradera.Techniques.DAL.Technique tec) { TechniqueModel model = new TechniqueModel() { ClubId = tec.ClubId, Description = tec.Description, TechniqueId = tec.Id, IsGlobal = tec.IsGlobal, Name = tec.Name, TechniqueTypeId = tec.TechniqueTypeId }; foreach (var image in tec.Technique_Image) { model.TechniqueImages.Add(new TechniqueImageModel() { Id = image.Id, ImageOrder = image.ImageOrder, Image = image.Image, TechniqueId = image.TechniqueId }); } return model; }
public HttpResponseMessage SaveTechnique(TechniqueModel technique) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); UserPrincipal loggedInUser = (UserPrincipal)HttpContext.Current.User; technique.ClubId = loggedInUser.AccountSession.ClubId; TechniqueAdminBLL.SaveTechnique(TechniqueModel.MapTechniqueToData(technique)); return response; }
public static Gradera.Techniques.DAL.Technique MapTechniqueToData(TechniqueModel model) { Gradera.Techniques.DAL.Technique tec = new Gradera.Techniques.DAL.Technique() { ClubId = model.ClubId, Description = model.Description, Id = model.TechniqueId, IsGlobal = model.IsGlobal, Name = model.Name, TechniqueTypeId = model.TechniqueTypeId }; model.TechniqueImages.ForEach(t => tec.Technique_Image.Add(new Gradera.Techniques.DAL.Technique_Image() { Id = t.Id, Image = t.Image, ImageOrder = t.ImageOrder, TechniqueId = t.TechniqueId })); return tec; }