public IHttpActionResult UpdateUsersGroups(List <UserGroupBindingModel> userGroup, int groupId)
        {
            if (userGroup == null || userGroup.Count() == 0)
            {
                ModelState.AddModelError("", "Grupa mora imati članove");
                return(BadRequest(ModelState));
            }



            var identity = (ClaimsIdentity)User.Identity;
            IEnumerable <Claim> claims = identity.Claims;
            var userId = int.Parse(claims.Where(c => c.Type == ClaimTypes.NameIdentifier).FirstOrDefault().Value);

            userGroup.Remove(userGroup.Where(ug => ug.UserId == userId).FirstOrDefault());
            var old = userGroupService.GetForUserAndGroup(userId, groupId);



            if (old.First().Group.UserId != userId)
            {
                return(Unauthorized());
            }

            var members = AutoMapper.Mapper.Map <List <UserGroupBindingModel>, List <UserGroup> >(userGroup);

            try
            {
                userGroupService.UpdateMembers(members, old.ToList());

                unitOfWork.Commit();
            }
            catch (Exception e)
            {
                return(BadRequest());
            }

            return(Ok());
        }