public async Task <IActionResult> Create([Bind("Id,Name,CASNum,Manufacturer,HasMSDS,HealthHazard,FlammableHazard,ReactiveHazard,OtherHazard,CurrentQty,Unit,DateReceived,IsCheckedOut,DateCheckedOut,DateReturned,Location,Consumed,HazWaste,Disposed")] Inventory inventory)
        {
            //var autoEmail = new MimeMessage();
            //autoEmail.From.Add(new MailboxAddress("*****@*****.**"));
            //autoEmail.To.Add(new MailboxAddress("*****@*****.**"));
            ////Lab instructor emails
            //// autoEmail.To.Add(new MailboxAddress("*****@*****.**"));
            //// autoEmail.To.Add(new MailboxAddress("*****@*****.**"));
            //autoEmail.Subject = "ELIMS Inventory Notification";
            //autoEmail.Body = new TextPart("plain")
            //{
            //    Text = @"A new inventory entry has been entered on the ELIMS webpage. Please click this link to manage: https://elims.azurewebsites.net/inventories. Do not reply to this email."
            //};

            //using (var client = new SmtpClient())
            //{
            //    client.ServerCertificateValidationCallback = (s, c, h, e) => true;

            //    client.Connect("smtp.gmail.com", 587, false);
            //    client.Authenticate("*****@*****.**", "NAULabs123");
            //    client.Send(autoEmail);
            //    client.Disconnect(true);
            //}

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(inventory));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Details(int id, [Bind("Id,UserId,StartDate,EndDate,RequestMade,FirstName,LastName,NAUEmail,ProjectName,ProjectObjective,ContactName,ContactID,Funding,SponsorName,SponsorPhone,SponsorEmail,Chemicals,MeetingTimes,GroupMembers,ProjectFile,Status,OwnerID")] Request request)
        {
            var status = request.Status;

            var r = await _context.Request.FindAsync(id);


            if (r == null)
            {
                return(NotFound());
            }

            if (id != request.Id)
            {
                return(NotFound());
            }

            var requestOperation = (status == RequestStatus.Approved) ? ELIMSOperations.Approve : ELIMSOperations.Deny;

            var isAuthorized = await _authorizationService.AuthorizeAsync(User, r, requestOperation);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }

            r.Status = status;
            _context.Request.Update(r);
            await _context.SaveChangesAsync();

            //var autoEmail = new MimeMessage();
            //autoEmail.From.Add(new MailboxAddress("*****@*****.**"));

            //// Email the user who made the request that their request has been updated
            //autoEmail.To.Add(new MailboxAddress(request.NAUEmail));
            //autoEmail.Subject = "ELIMS Lab Request Notification";
            //autoEmail.Body = new TextPart("plain")
            //{
            //    Text = @"There has been an update to your lab usage request. Please click this link to view it: https://elims.azurewebsites.net/request. Do not reply to this email. Thank you!"
            //};

            //using (var client = new SmtpClient())
            //{
            //    client.ServerCertificateValidationCallback = (s, c, h, e) => true;


            //    client.Connect("smtp.gmail.com", 587, false);
            //    client.Authenticate("*****@*****.**", "NAULabs123");
            //    client.Send(autoEmail);
            //    client.Disconnect(true);
            //}

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Name,StartDate,EndDate")] BioRaft bioRaft)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bioRaft);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bioRaft));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,CFirstName,CLastName,UserId,CEmail,Topic,Message,ContactDate")] ContactForm contactForm)
        {
            //var autoEmail = new MimeMessage();
            //autoEmail.From.Add(new MailboxAddress("*****@*****.**"));
            //autoEmail.To.Add(new MailboxAddress("*****@*****.**"));
            ////Lab instructor emails
            //// autoEmail.To.Add(new MailboxAddress("*****@*****.**"));
            //// autoEmail.To.Add(new MailboxAddress("*****@*****.**"));
            //autoEmail.Subject = "ELIMS Contact Notification";
            //autoEmail.Body = new TextPart("plain")
            //{
            //    Text = @"You have recieved a contact information form from the ELIMS webpage. Please click this link to manage: https://elims.azurewebsites.net/ContactForms. Do not reply to this email."
            //};

            //using (var client = new SmtpClient())
            //{
            //    client.ServerCertificateValidationCallback = (s, c, h, e) => true;

            //    client.Connect("smtp.gmail.com", 587, false);
            //    client.Authenticate("*****@*****.**", "NAULabs123");
            //    client.Send(autoEmail);
            //    client.Disconnect(true);
            //}


            if (ModelState.IsValid)
            {
                contactForm.OwnerID = _userManager.GetUserId(User);

                var isAuthorized = await _authorizationService.AuthorizeAsync(User, contactForm, ELIMSOperations.Create);

                // If not authorized
                if (!isAuthorized.Succeeded)
                {
                    _context.Add(contactForm);
                    await _context.SaveChangesAsync();

                    return(View("./Views/Home/Index.cshtml"));
                }

                _context.Add(contactForm);
                await _context.SaveChangesAsync();

                return(View("./Views/Home/Index.cshtml"));
            }
            return(View("/Home/Index"));
        }