Ejemplo n.º 1
0
        public void UpdateUser(UserDto user)
        {
            if (user == null)
            {
                var fault = new ArgumentFault
                {
                    Message      = "Argumnet is null",
                    ArgumentName = nameof(user)
                };

                throw new FaultException <ArgumentFault>(fault);
            }

            ApplicationUser userEntity = Mapper.Map <ApplicationUser>(user);

            _userBusinessLogic.UpdateUser(userEntity);
        }
Ejemplo n.º 2
0
 public void UpdateUser(Person obj)
 {
     _userBl.UpdateUser(obj);
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id,
                                               [Bind("SpeakerId,CodecampUserId,FirstName,LastName,CompanyName,ImageFile,ResizeImage,Bio,WebsiteUrl,BlogUrl,GeographicLocation,TwitterHandle,LinkedIn,IsVolunteer,IsMvp,NoteToOrganizers,Email,PhoneNumber,IsApproved")] SpeakerViewModel speakerVM)
        {
            if (ModelState.IsValid)
            {
                if (id != speakerVM.SpeakerId)
                {
                    return(NotFound());
                }

                var speaker = await _speakerBL.GetSpeaker(id);

                // Update the speaker information from the page
                speaker.CompanyName      = speakerVM.CompanyName;
                speaker.Bio              = speakerVM.Bio;
                speaker.WebsiteUrl       = speakerVM.WebsiteUrl;
                speaker.BlogUrl          = speakerVM.BlogUrl;
                speaker.NoteToOrganizers = speakerVM.NoteToOrganizers;
                speaker.IsApproved       = speakerVM.IsApproved;
                speaker.IsMvp            = speakerVM.IsMvp;
                speaker.LinkedIn         = speakerVM.LinkedIn;
                speaker.CodecampUserId   = speakerVM.CodecampUserId;

                // Convert the image to a byte array, reduce the size to 300px x 300px
                // and store it in the database
                if (speakerVM.ImageFile != null &&
                    speakerVM.ImageFile.ContentType.ToLower().StartsWith("image/") &&
                    speakerVM.ImageFile.Length <= SpeakerViewModel.MaxImageSize)
                {
                    MemoryStream ms = new MemoryStream();
                    speakerVM.ImageFile.OpenReadStream().CopyTo(ms);

                    speaker.Image
                        = _speakerBL.ResizeImage(ms.ToArray());
                }

                var result = await _speakerBL.UpdateSpeaker(speaker);

                var user = await _userBL.GetUser(speakerVM.CodecampUserId);

                // Update the user information from the page
                user.FirstName          = speakerVM.FirstName;
                user.LastName           = speakerVM.LastName;
                user.GeographicLocation = speakerVM.GeographicLocation;
                user.TwitterHandle      = speakerVM.TwitterHandle;
                user.IsVolunteer        = speakerVM.IsVolunteer;
                user.Email       = speakerVM.Email;
                user.PhoneNumber = speakerVM.PhoneNumber;

                result &= await _userBL.UpdateUser(user);

                if (result == false)
                {
                    return(NotFound());
                }
                else
                {
                    return(RedirectToAction(nameof(Index)));
                }
            }

            return(View(speakerVM));
        }