예제 #1
0
        public ActionResult Edit(int id)
        {
            var service = CreateWorkoutTypeService();
            var detail  = service.GetWorkoutTypeById(id);
            var model   =
                new WorkoutTypeEdit
            {
                WorkoutTypeId = detail.WorkoutTypeId,
                Type          = detail.Type
            };

            return(View(model));
        }
예제 #2
0
        public bool UpdateWorkoutType(WorkoutTypeEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .WorkoutType
                    .Single(e => e.WorkoutTypeId == model.WorkoutTypeId && e.UserId == model._userId);

                entity.Type        = model.Type;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }