public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Age,Gender,Bio,UserAccountId,DisplayName")] DatingProfile datingProfile,
                                                 IFormFile FilePhoto)
        {
            if (FilePhoto.Length > 0)
            {
                string photoPath = _webroot.WebRootPath + "\\userPhotos\\";
                var    fileName  = Path.GetFileName(FilePhoto.FileName);

                using (var stream = System.IO.File.Create(photoPath + fileName))
                {
                    await FilePhoto.CopyToAsync(stream);

                    datingProfile.PhotoPath = fileName;
                }
            }

            if (ModelState.IsValid)
            {
                _context.Add(datingProfile);
                await _context.SaveChangesAsync();

                return(RedirectToAction("ProfileInfo"));
            }
            return(View(datingProfile));
        }
Beispiel #2
0
        public IActionResult Send([Bind("MessageTitle, MessageText")] MailMessages mail, int toProfileId)
        {
            DatingProfile fromUser = _context.DatingProfile.FirstOrDefault(p => p.UserAccountId == _userManager.GetUserId(User));

            mail.FromProfileId = fromUser.Id;
            mail.IsRead        = false;
            mail.FromProfile   = fromUser;
            mail.ToProfileId   = toProfileId;

            _context.Add(mail);
            _context.SaveChanges();

            return(RedirectToAction("Browse", "DatingProfiles"));
        }