public IHttpActionResult UpdateInfluencerUser(UpdatedInfluencerUserModal userToUpdate)
        {
            ErrorMessage errorMessage = influencerUsersBL.UpdateInfluencerUser(userToUpdate);

            if (errorMessage.Code == HttpStatusCode.OK)
            {
                User updatedUser = usersBL.GetUserByEmail(userToUpdate.Email);
                return(Ok(updatedUser));
            }

            return(new ResponseMessageResult(Request.CreateErrorResponse(
                                                 errorMessage.Code,
                                                 new HttpError(errorMessage.Message)
                                                 )
                                             ));
        }
예제 #2
0
        public void UpdateInfluencerUser(UpdatedInfluencerUserModal userToUpdate)
        {
            User CurrUser = context.Users.FirstOrDefault(u => u.Email == userToUpdate.Email);

            if (CurrUser != null)
            {
                CurrUser.Name = userToUpdate.Name;
                if (userToUpdate.Interests != null)
                {
                    ICollection <Interest> newInterests = new List <Interest>();
                    (CurrUser as InfluencerUser).Interests.Clear();

                    foreach (var newInterest in userToUpdate.Interests)
                    {
                        newInterests.Add(newInterest);
                    }

                    (CurrUser as InfluencerUser).Interests = newInterests;
                }


                CurrUser.Picture     = userToUpdate.Picture;
                CurrUser.Description = userToUpdate.Description;
                if (userToUpdate.SocialNetworks != null)
                {
                    ICollection <SocialNetwork> newSocialNetworks = new List <SocialNetwork>();
                    (CurrUser as InfluencerUser).SocialNetworks.Clear();

                    foreach (var newSocialNetwork in userToUpdate.SocialNetworks)
                    {
                        newSocialNetworks.Add(newSocialNetwork);
                    }

                    (CurrUser as InfluencerUser).SocialNetworks = newSocialNetworks;
                }
                context.SaveChanges();
            }
        }
예제 #3
0
        public ErrorMessage UpdateInfluencerUser(UpdatedInfluencerUserModal userToUpdate)
        {

            userCRUD.UpdateInfluencerUser(userToUpdate);
            User user = userCRUD.GetUserByEmail(userToUpdate.Email);
            if (user == null)
            {
                ErrorMessage message = new ErrorMessage
                {
                    Message = "User does not exist",
                    Code = HttpStatusCode.NotModified
                };
                return message;
            }
            else
            {
                ErrorMessage message = new ErrorMessage
                {
                    Code = HttpStatusCode.OK
                };
                return message;
            }
        }