Example #1
0
        public ActionResult Create(UserGroupVM model)
        {
            try
            {
                string userGroupId = string.Empty;
                model.CreatedBy = LogInManager.LoggedInUserId;

                #region Check User Group Name Exist.

                if (this.CheckUserGroupNameExist(model.Id, model.Name) == false)
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = string.Format("Name : {0} already exist.", model.Name)
                    }, JsonRequestBehavior.AllowGet));
                }

                #endregion

                userGroupId = userGroupRepository.AddUserGroup(model);

                if (!string.IsNullOrWhiteSpace(userGroupId))
                {
                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            UserGroupId = userGroupId
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "User Group details not saved successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "Create");
                return(Json(new
                {
                    IsSuccess = false,
                    errorMessage = e.Message
                }));
            }
        }
 public int AddUserGroup(UserGroup ug, out string msg)
 {
     return(ugRepo.AddUserGroup(ug, out msg));
 }
        public ActionResult AddUserGroup(CreateUserGroupRequest createRequest)
        {
            var newUserGroup = _repository.AddUserGroup(createRequest.UserEmail, createRequest.GroupId);

            return(Created($"api/userGroup/{newUserGroup.Id}", newUserGroup));
        }