예제 #1
0
        public bool UpdatePlan(MealPlan item)
        {
            var editItem = _panRepository.Get(item.ID);

            if (editItem == null)
            {
                return(false);
            }
            editItem.Name        = item.Name;
            editItem.Description = item.Description;
            editItem.Tags        = item.Tags;
            editItem.UpdateTime  = DateTime.Now;
            item.UpdateTime      = DateTime.Now;
            _panRepository.Update(item);
            return(true);
        }
예제 #2
0
        public long CreatePlan(string name, string description, string[] tags, IList <MealItem> mealItems)
        {
            MealPlan plan = new MealPlan()
            {
                Description = description,
                Name        = name,
                Tags        = tags,
                Createtime  = DateTime.Now,
                UpdateTime  = DateTime.Now,
            };
            var planid = _panRepository.Create(plan);

            foreach (var item in mealItems)
            {
                item.PlanID     = planid;
                item.Createtime = DateTime.Now;
                item.UpdateTime = DateTime.Now;
            }
            _itemRepository.Create(mealItems);
            return(planid);
        }