Пример #1
0
        public async Task <ActionResult> Upload(IFormFile file)
        {
            string userId  = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var    uploads = context.FindUploadsByUserId(userId).ToList();

            if (uploads == null)
            {
                uploads = new List <SheetUpload>();
            }

            if (file != null && file.Length > 0)
            {
                try
                {
                    var upload = readSheet.toSheetUpload(file, userId);
                    uploads.Add(upload);
                    context.Add <SheetUpload>(upload);
                    context.SaveChanges();

                    await emailService.SendConfirmationEmails(upload);

                    ViewBag.Message = "File uploaded successfully";
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERROR:" + ex.Message.ToString();
                }
            }
            else
            {
                ViewBag.Message = "You have not specified a file.";
            }
            return(View("Upload", uploads));
        }
Пример #2
0
        public async Task <ActionResult> Confirm(int id, string email)
        {
            //gets the person who clicks the confirm in their email (from the method's parameters)
            var person = await context.People.Include(c => c.Emails).SingleAsync(c => c.Id == id);

            //since each person has 2 emails, this determines which email the person confirmed
            foreach (var e in person.Emails)
            {
                if (e.EmailAddress == email)
                {
                    e.IsConfirmed = true;
                }
            }

            //this saves the e.IsConfirmed = true to the database
            context.SaveChanges();

            return(View());
        }