Esempio n. 1
0
        private void CreateUserGroupService(UserGroupDto NewUserGroup, UserDto currentUser)
        {
            UserGroupServiceClient client = new UserGroupServiceClient();

            try
            {
                if (FormMode == "edit")
                {
                    NewUserGroup.UserGroupId = Id;
                    NewUserGroup             = client.Update(NewUserGroup, currentUser.UserName);
                }
                else
                {
                    NewUserGroup.CreatedBy = currentUser.UserId;
                    NewUserGroup           = client.Create(NewUserGroup, currentUser.UserName);
                }
                if (NewUserGroup.Response.HasWarning)
                {
                    foreach (BusinessWarning businessWarning in NewUserGroup.Response.BusinessWarnings)
                    {
                        ViewData["Error"] = ErrorAndValidationMessages.ResourceManager.GetString(businessWarning.Message);
                    }
                }
                else
                {
                    if (FormMode == "edit")
                    {
                        TempData["GroupSaved"] = String.Format(ClientResources.UserGroupUpdated, NewUserGroup.UserGroupName);
                    }
                    else
                    {
                        TempData["GroupSaved"] = String.Format(ClientResources.UserGroupAdded, NewUserGroup.UserGroupName);
                    }
                    isGroupSaved = true;
                }
            }
            catch (Exception)
            {
                client.Close();
            }
        }