Exemple #1
0
        public void CreateBlock(BlockPostModel model, int currUserId)
        {
            var plan = _unitOfWork.Repository <PlanEntity>()
                       .Include(x => x.Owner).
                       FirstOrDefault(x => x.Owner.Id == currUserId && x.Id == model.PlanId);

            _unitOfWork.Repository <BlockExersiceEntity>().Insert(new BlockExersiceEntity
            {
                Exersices = new List <ExerciseEntity>(),
                Name      = model.Name,
                Plan      = plan
            });
            _unitOfWork.SaveChanges();
        }
        public IHttpActionResult CreateBlock(BlockPostModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                _blockOperations.CreateBlock(model, _currentUserProvider.CurrentUserId);
                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));

                throw;
            }
        }