Beispiel #1
0
        public ModelResponse UpdateOrgContact(UserInfo user, ref OrgContactVm vm)
        {
            try
            {
                //Authorization
                if (user == null)
                {
                    return(new ModelResponse(101));
                }
                if (string.IsNullOrWhiteSpace(user.UserId))
                {
                    return(new ModelResponse(101));
                }
                if (PUserRepo.GetUserClass(user) != UserClass.OrgAdmin)
                {
                    return(new ModelResponse(101));
                }

                //Validations
                if (vm.UserName.HasNoValue() ||
                    vm.FullName.IsNullOrWhiteSpace() ||
                    vm.Department.IsNullOrWhiteSpace() ||
                    vm.JobTitle.IsNotASubCode())
                {
                    return(new ModelResponse(1));
                }

                //Save to DB
                vm.PortalUserId = (long)user.PortalUserId;
                Repo.UpdateOrgContact(ref vm, user.UserId);
            }
            catch (Exception ex)
            {
                return(new ModelResponse(ex));
            }

            return(new ModelResponse(0, vm.ContactId));
        }