public bool Add(WorkoutCategoryDetailDTO entity) { WorkoutCategory workoutCategory = new WorkoutCategory(); workoutCategory.Name = entity.Name; return(dao.Add(workoutCategory)); }
protected void Page_Load(object sender, EventArgs e) { Assert.ArgumentNotNull(currentGuid, "Source category guid is null"); Assert.ArgumentNotNullOrEmpty(ItemPaths.WorkoutCategories, "Workout category paths empty"); List<WorkoutCategory> categoryList = new List<WorkoutCategory>(); foreach (Item category in Sitecore.Context.Database.GetItem(ItemPaths.WorkoutCategories).Children) { DropDownItem cat = new DropDownItem(category); if (category.ID.ToString().Equals(CurrentGuid)) { ContextCategory = new WorkoutCategory(cat.ID.ToString(), cat.Id.Raw, cat.Value.Raw, Sitecore.Context.Item); categoryList.Add(ContextCategory); } else { categoryList.Add(new WorkoutCategory(cat.ID.ToString(), cat.Id.Raw, cat.Value.Raw)); } } CategoryList.DataSource = categoryList; ZoneLinkList.DataSource = ContextCategory.WorkoutZones; ZoneList.DataSource = ContextCategory.WorkoutZones; CategoryList.DataBind(); ZoneLinkList.DataBind(); ZoneList.DataBind(); }
public bool Delete(int ID) { WorkoutCategory category = db.WorkoutCategories.First(x => x.ID == ID); db.WorkoutCategories.Remove(category); db.SaveChanges(); return(true); }
public void Update(WorkoutCategoryDetailDTO entity) { WorkoutCategory category = new WorkoutCategory(); category.ID = entity.ID; category.Name = entity.Name; dao.Update(category); }
public void Update(WorkoutCategory entity) { try { WorkoutCategory category = db.WorkoutCategories.First(x => x.ID == entity.ID); category.Name = entity.Name; db.SaveChanges(); } catch (Exception ex) { throw ex; } }
public bool Add(WorkoutCategory entity) { try { db.WorkoutCategories.Add(entity); db.SaveChanges(); return(true); } catch (Exception ex) { throw ex; } }
public HttpResponseMessage DeleteCategory(WorkoutCategory wc) { try { var input = Helper.CastObject <workout_category>(wc); _workoutCategoryService.DeleteWorkoutCategory(input); } catch (Exception ex) { _logManager.WriteLog(ex); } return(ToJson(wc)); }
public HttpResponseMessage GetCategory(WorkoutCategory wc) { WorkoutCategory result = new WorkoutCategory(); try { var res = _workoutCategoryService.GetCategory(wc.category_id); MapCategory(res, ref result); } catch (Exception ex) { _logManager.WriteLog(ex); } return(ToJson(result)); }
public HttpResponseMessage AddCategory(WorkoutCategory wc) { WorkoutCategory result = new WorkoutCategory(); try { var input = Helper.CastObject <workout_category>(wc); var res = _workoutCategoryService.Create(input); MapCategory(res, ref result); } catch (Exception ex) { _logManager.WriteLog(ex); } return(ToJson(result)); }
public bool IsCategoryExist(string text) { try { WorkoutCategory category = db.WorkoutCategories.FirstOrDefault(x => x.Name == text); if (category != null) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
private void MapCategory(workout_category source, ref WorkoutCategory des) { des.category_id = source.category_id; des.category_name = source.category_name; des.workout_collection = Helper.CastObject <IList <WorkoutCollection> >(source.workout_collection); }