示例#1
0
        public ActionResult ResumeUpload()
        {
            AlumniDBModel db    = new AlumniDBModel();
            var           image = Request.Files["resume"];

            if (image == null)
            {
                ViewBag.UploadMessage = "Failed to upload image";
            }
            else
            {
                Stream resumeStream = image.InputStream;

                ContactProfile profileId = (from contact in db.ContactProfiles
                                            where contact.PrimaryEmail == User.Identity.Name
                                            select contact).FirstOrDefault();
                UserResume refreshModel = db.UserResumes.FirstOrDefault(r => r.ProfileID == profileId.ProfileId);

                byte[] resumeBytes;

                using (BinaryReader binaryData = new BinaryReader(resumeStream))
                {
                    resumeBytes = binaryData.ReadBytes((int)resumeStream.Length);//must convert long to int
                }

                refreshModel.ResumeImg       = resumeBytes;
                db.Entry(refreshModel).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(RedirectToAction("Edit", "Admin"));
        }
示例#2
0
        public async Task <ExecutionResult <Guid> > InsertContactProfile(ContactProfileViewModel viewModel)
        {
            ContactProfile contactProfile = _mapper.Map <ContactProfileViewModel, ContactProfile>(viewModel);

            contactProfile.ContactProfileId = Guid.NewGuid();
            return(await _iContactProfileRepository.InsertContactProfile(contactProfile));
        }
示例#3
0
        public ActionResult ImageUploadPhotoEdit2(int ProjectSpotlightID)
        {
            var image = Request.Files["image2"];

            if (image == null)
            {
                ViewBag.UploadMessage = "Failed to upload image";
            }
            else
            {
                ViewBag.UploadMessage = String.Format("Got image {0} of type {1} and size {2}",
                                                      image.FileName, image.ContentType, image.ContentLength);

                Stream photoStream = image.InputStream;

                ContactProfile profileId = (from contact in db.ContactProfiles
                                            where contact.PrimaryEmail == User.Identity.Name
                                            select contact).FirstOrDefault();
                ProjectSpotlight refreshModel = db.ProjectSpotlights.FirstOrDefault(r => r.ProjectSpotlightID == ProjectSpotlightID);
                byte[]           photoBytes;

                using (BinaryReader binaryData = new BinaryReader(photoStream))
                {
                    photoBytes = binaryData.ReadBytes((int)photoStream.Length);//must convert long to int
                }

                refreshModel.SpotlightImg_2 = photoBytes;

                db.Entry(refreshModel).State = EntityState.Modified;
                db.SaveChanges();
            }
            ProjectSpotlight finalRefreshModel = db.ProjectSpotlights.FirstOrDefault(r => r.ProjectSpotlightID == ProjectSpotlightID);

            return(View("EditProject", finalRefreshModel));
        }
示例#4
0
        public ActionResult ImageUploadPhoto()
        {
            var image = Request.Files["image"];

            if (image == null)
            {
                ViewBag.UploadMessage = "Failed to upload image";
            }
            else
            {
                Stream photoStream = image.InputStream;
                ViewBag.UploadMessage = String.Format("Got image {0} of type {1} and size {2}",
                                                      image.FileName, image.ContentType, image.ContentLength);


                ContactProfile refreshModel = db.ContactProfiles.FirstOrDefault(r => r.PrimaryEmail == User.Identity.Name);

                byte[] photoBytes;

                using (BinaryReader binaryData = new BinaryReader(photoStream))
                {
                    photoBytes = binaryData.ReadBytes((int)photoStream.Length);//must convert long to int
                }

                refreshModel.Img = photoBytes;

                db.Entry(refreshModel).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(RedirectToAction("Edit", "Admin"));
        }
示例#5
0
 public async Task <int> DeleteContactProfileAsync(ContactProfile model)
 {
     if (model.Id != null || model.Id != Guid.Empty)
     {
         _context.ContactProfile.Remove(model);
     }
     return(await _context.SaveChangesAsync());
 }
        //allows images to be uploaded (png, png, gif's. PDF's will not work for storing profile images
        //used for the profile img
        public ActionResult GetImg(int ProfileId)
        {
            ContactProfile profile = db.ContactProfiles.Single(p => p.ProfileId == ProfileId);

            if (profile != null && profile.Img != null)
            {
                return(new FileContentResult(profile.Img, "image/png"));
            }
            return(null);
        }
        //allows images to be uploaded (png, png, gif's. PDF's will not work for storing profile images
        public ActionResult GetProfileImg(string ProfileEmail)
        {
            ContactProfile contact = db.ContactProfiles.Single(r => r.PrimaryEmail == ProfileEmail);

            if (contact != null && contact.Img != null)
            {
                return(new FileContentResult(contact.Img, "image/png"));
            }
            return(null);
        }
示例#8
0
        public HomeControllerTest()
        {
            var contactprofile = new ContactProfile();

            _repository = new MockContactsRepo();
            var mapperConfiguration = new MapperConfiguration(cfg => { cfg.AddProfile(contactprofile); });

            _mapper = mapperConfiguration.CreateMapper();
            var random = new Random();

            _controller = new HomeController(_repository, _mapper);
        }
示例#9
0
 public async Task <int> InsertOrUpdatetContactProfileAsync(ContactProfile model)
 {
     if (model.Id == null || model.Id == Guid.Empty)
     {
         await _context.ContactProfile.AddAsync(model);
     }
     else
     {
         _context.ContactProfile.Update(model);
     }
     return(await _context.SaveChangesAsync());
 }
示例#10
0
 public async Task <int> InsertContactProfileAsync(ContactProfile model)
 {
     try
     {
         if (model.Id == null || model.Id == Guid.Empty)
         {
             await _context.ContactProfile.AddAsync(model);
         }
         return(await _context.SaveChangesAsync());
     }
     catch (Exception)
     {
         throw;
     }
 }
 /// <summary>
 /// Initializes a new instance for the <see cref="ContactProfileViewModel" /> class.
 /// </summary>
 public ContactProfileViewModel(IUserService userService, IProfileService profileService,
                                IAudioService audioService, PlayerService playerService, ContactProfilePage page)
 {
     page.Appearing         += PageOnAppearing;
     this.userService        = userService;
     this.profileService     = profileService;
     this.audioService       = audioService;
     this.playerService      = playerService;
     this.page               = page;
     ProfileInfo             = new ContactProfile();
     ProfileNameCommand      = new Command(ProfileNameClicked);
     EditCommand             = new Command(EditButtonClicked);
     ViewAllCommand          = new Command(ViewAllButtonClicked);
     SelectionChangedCommand = new Command(SelectionChanged);
     RemoveTrackCommand      = new Command(RemoveTrackClicked);
 }
        public async Task <ExecutionResult <Guid> > InsertContactProfile(ContactProfile model)
        {
            try
            {
                await _appDbContext.ContactProfiles.AddAsync(model);

                var i = await _appDbContext.SaveChangesAsync() > 0;

                var result = new ExecutionResult <Guid>(i, model.ContactProfileId);
                return(result);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
        }
示例#13
0
        public async Task <IActionResult> Create([Bind("FirstName,LastName,PreferredName,AddressId,PrimaryPassword,IsDeactivated,ProfilePictureId,EmailAllowed,SmsAllowed,RegistrationDate,DateOfBirth,GenderTypeId,IsArchived,CreatedDate,CreatedBy,UpdatedDate,UpdatedBy,IsDeleted,DeletedBy,DeletedDate,Id")] ContactProfile contactProfile)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    contactProfile.Id = Guid.NewGuid();
                    _context.Add(contactProfile);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(contactProfile));
            }
            catch (Exception ex)
            {
                return(ErrorView(ex));
            }
        }
示例#14
0
        public async Task <IActionResult> Edit(Guid id, [Bind("FirstName,LastName,PreferredName,AddressId,PrimaryPassword,IsDeactivated,ProfilePictureId,EmailAllowed,SmsAllowed,RegistrationDate,DateOfBirth,GenderTypeId,IsArchived,CreatedDate,CreatedBy,UpdatedDate,UpdatedBy,IsDeleted,DeletedBy,DeletedDate,Id")] ContactProfile contactProfile)
        {
            try
            {
                var contactProfileViewModel = await _iContactProfileManager.GetContactProfileAsync(id);

                var model = _iMapper.Map <ContactProfileViewModel, ContactProfilePageViewModel>(contactProfileViewModel);

                if (id == contactProfile.Id)
                {
                    if (ModelState.IsValid)
                    {
                        try
                        {
                            _context.Update(contactProfile);
                            await _context.SaveChangesAsync();
                        }
                        catch (DbUpdateConcurrencyException)
                        {
                            if (!ContactProfileExists(contactProfile.Id))
                            {
                                return(NotFound());
                            }
                            else
                            {
                                throw;
                            }
                        }
                        return(RedirectToAction(nameof(Index)));
                    }
                    return(View(contactProfile));
                }
                else
                {
                    return(ErrorView(ExceptionHelper.ExceptionErrorMessageForNullObject()));
                }
            }
            catch (Exception ex)
            {
                return(ErrorView(ex));
            }
        }
示例#15
0
        public static PSContactProfile ToPSContactProfile(this ContactProfile sdkContactProfile)
        {
            if (sdkContactProfile == null)
            {
                return(null);
            }

            return(new PSContactProfile
            {
                FirstName = sdkContactProfile.FirstName,
                LastName = sdkContactProfile.LastName,
                PhoneNumber = sdkContactProfile.PhoneNumber,
                Country = sdkContactProfile.Country,
                PreferredContactMethod = sdkContactProfile.PreferredContactMethod,
                PreferredTimeZone = sdkContactProfile.PreferredTimeZone,
                PreferredSupportLanguage = sdkContactProfile.PreferredSupportLanguage,
                PrimaryEmailAddress = sdkContactProfile.PrimaryEmailAddress,
                AdditionalEmailAddresses = sdkContactProfile.AdditionalEmailAddresses?.ToArray()
            });
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    await this.UserManager.AddToRoleAsync(user.Id, model.Name);


                    AlumniDBModel db = new AlumniDBModel();

                    ContactProfile newContact = new ContactProfile();
                    newContact.FirstName    = user.FirstName;
                    newContact.LastName     = user.LastName;
                    newContact.PrimaryEmail = user.Email;
                    db.ContactProfiles.Add(newContact);

                    db.Entry(newContact).State = EntityState.Added;

                    db.SaveChanges();

                    ContactProfile profileId = (from contact in db.ContactProfiles
                                                where contact.PrimaryEmail == user.Email
                                                select contact).FirstOrDefault();

                    //string connectionStringResume = ConfigurationManager.ConnectionStrings[2].ConnectionString;

                    //using (SqlConnection connection = new SqlConnection(connectionStringResume))
                    //{
                    //    connection.Open();



                    //    UserResume newResume = new UserResume();
                    //    newResume.ProfileID = profileId.ProfileId;
                    //    newResume.HtmlUpload = " ";
                    //    db.UserResumes.Add(newResume);

                    //    SqlCommand cmd = new SqlCommand("INSERT INTO UserResume(ProfileID,HtmlUpload) Values (@fName,@html)");
                    //    cmd.CommandType = CommandType.Text;
                    //    cmd.Connection = connection;
                    //    cmd.Parameters.AddWithValue("@fName", profileId.ProfileId);
                    //    cmd.Parameters.AddWithValue("@html", ' ');

                    //    cmd.ExecuteNonQuery();

                    //}

                    UserResume newResume = new UserResume();
                    newResume.ProfileID  = profileId.ProfileId;
                    newResume.HtmlUpload = " ";


                    db.UserResumes.Add(newResume);

                    db.SaveChanges();



                    //UserResume newResume = new UserResume();
                    //newResume.ContactProfile = profileId;
                    //newResume.ProfileID = profileId.ProfileId;
                    //newResume.HtmlUpload = " ";
                    //db.UserResumes.Add(newResume);



                    //db.SaveChanges();

                    ModelState.Clear();
                    ViewBag.Name = new SelectList(context.Roles.ToList(), "Name", "Name");
                    return(View());
                }
                AddErrors(result);
            }
            ViewBag.Name = new SelectList(context.Roles.ToList(), "Name", "Name");
            // If we got this far, something failed, redisplay form
            return(View());
        }
        // GET: UserProfile
        public ActionResult Index(int?id)
        {
            //  --- Insert Database Pull for matching user ID here ---
            UserProfileViewModels model = new UserProfileViewModels();
            ContactProfile        dbContactProfileModel = db.ContactProfiles.FirstOrDefault(i => i.ProfileId == id);

            try
            {
                // Copy over Data
                model.About                   = dbContactProfileModel.About;
                model.Address                 = dbContactProfileModel.StreetAddress;
                model.AlternateEmail          = dbContactProfileModel.AlternateEmail;
                model.AlternatePhone          = dbContactProfileModel.AlternatePhone;
                model.AvailableForWorkMessage = ""; // dbContactProfileModel.AvailableForWorkMessage;
                model.City    = dbContactProfileModel.City;
                model.Country = dbContactProfileModel.Country;
                model.CurrentlyWorkingOnMessage = dbContactProfileModel.CurrentWork;
                model.GitHubProfile             = dbContactProfileModel.GitHub;
                model.HireByMessage             = dbContactProfileModel.HiredBy;
                model.LinkInProfile             = dbContactProfileModel.LinkedIn;
                model.PersonalWebsite           = dbContactProfileModel.PersonalWebsite;
                model.PrimaryEmail                  = dbContactProfileModel.PrimaryEmail;
                model.PrimaryPhone                  = dbContactProfileModel.PrimaryPhone;
                model.ProfilePhoto                  = dbContactProfileModel.Photo;
                model.ShowAddress                   = dbContactProfileModel.ShowAddress;
                model.ShowAlternateEmail            = dbContactProfileModel.ShowAlternateEmail;
                model.ShowAlternatePhone            = dbContactProfileModel.ShowAlternatePhone;
                model.ShowAvailableForWorkMessage   = dbContactProfileModel.ShowAvailableForWork;
                model.ShowCurrentlyWorkingOnMessage = dbContactProfileModel.ShowCurrentlyWorking;
                model.ShowGitHubProfile             = dbContactProfileModel.ShowGitHubLink;
                model.ShowHireByMessage             = dbContactProfileModel.ShowHireByMessage;
                model.ShowLinkInProfile             = dbContactProfileModel.ShowLinkedInLink;
                model.ShowPersonalWebsite           = dbContactProfileModel.ShowPersonalWebsiteLink;
                model.ShowPrimaryEmail              = dbContactProfileModel.ShowPrimaryEmail;
                model.ShowPrimaryPhone              = dbContactProfileModel.ShowPrimaryPhone;
                model.ShowProfilePhoto              = dbContactProfileModel.ShowProfilePhoto;
                model.ShowResume    = true; // dbContactProfileModel.ShowResume;
                model.State         = dbContactProfileModel.USAState;
                model.UserFirstName = dbContactProfileModel.FirstName;
                model.UserLastName  = dbContactProfileModel.LastName;
                model.Zip           = dbContactProfileModel.PostalCode;

                // Generate Project List
                List <ProjectSpotlight> dbProjectList = db.ProjectSpotlights.Where(p => p.ProfileID == id).ToList();
                model.ProjectSpotLightObjectList = new List <ProjectSpotlight>();
                foreach (ProjectSpotlight projectItem in dbProjectList)
                {
                    model.ProjectSpotLightObjectList.Add(projectItem);
                }


                // Pull resume from database
                model.ResumeHtmlUpload = db.UserResumes.FirstOrDefault(i => i.ProfileID == id);

                return(View(model));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
 public Task <ExecutionResult <bool> > UpdateDonationInfo(ContactProfile model)
 {
     throw new NotImplementedException();
 }