Beispiel #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Review = await _context.Review.FindAsync(id);

            if (Review != null)
            {
                _context.Review.Remove(Review);

                var auditrecord = new AuditRecord();
                auditrecord.AuditActionType    = "Deleted a Review";
                auditrecord.DateTimeStamp      = DateTime.Now;
                auditrecord.KeySoftwareFieldID = 0;
                // Get current logged-in user
                var userID = User.Identity.Name.ToString();
                auditrecord.Username = userID;

                _context.AuditRecords.Add(auditrecord);


                await _context.SaveChangesAsync();

                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Software.Add(Software);
            //await _context.SaveChangesAsync();
            if (await _context.SaveChangesAsync() > 0)
            {
                // Create an auditrecord object
                var auditrecord = new AuditRecord();
                auditrecord.AuditActionType    = "Add Software Record (Software: " + Software.Name + ")";
                auditrecord.DateTimeStamp      = DateTime.Now;
                auditrecord.KeySoftwareFieldID = Software.ID;
                // Get current logged-in user
                var userID = User.Identity.Name.ToString();
                auditrecord.Username = userID;

                _context.AuditRecords.Add(auditrecord);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Software = await _context.Software.FindAsync(id);

            if (Software != null)
            {
                _context.Software.Remove(Software);
                //await _context.SaveChangesAsync();
                if (await _context.SaveChangesAsync() > 0)
                {
                    var auditrecord = new AuditRecord();
                    auditrecord.AuditActionType    = "Delete Software Record (Software: " + Software.Name + ")";
                    auditrecord.DateTimeStamp      = DateTime.Now;
                    auditrecord.KeySoftwareFieldID = Software.ID;
                    var userID = User.Identity.Name.ToString();
                    auditrecord.Username = userID;
                    _context.AuditRecords.Add(auditrecord);
                    await _context.SaveChangesAsync();
                }
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #4
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(AuditRecord).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AuditRecordExists(AuditRecord.Audit_ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Software).State = EntityState.Modified;

            try
            {
                var auditrecord = new AuditRecord();
                auditrecord.AuditActionType    = "Edit Software Record (Software: " + Software.Name + ")";
                auditrecord.DateTimeStamp      = DateTime.Now;
                auditrecord.KeySoftwareFieldID = Software.ID;
                var userID = User.Identity.Name.ToString();
                auditrecord.Username = userID;
                _context.AuditRecords.Add(auditrecord);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SoftwareExists(Software.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            Review.Username    = User.Identity.Name;
            Review.DateCreated = DateTime.Now;

            _context.Review.Add(Review);

            var auditrecord = new AuditRecord();

            auditrecord.AuditActionType    = "Added a Review";
            auditrecord.DateTimeStamp      = DateTime.Now;
            auditrecord.KeySoftwareFieldID = 0;
            // Get current logged-in user
            var userID = User.Identity.Name.ToString();

            auditrecord.Username = userID;

            _context.AuditRecords.Add(auditrecord);


            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            Software = await _context.Software.FindAsync(Id);

            if (ModelState.IsValid)
            {
                OrderEmail = User.Identity.Name;
                int           i    = 0;
                List <string> keys = new List <string>();
                while (i < OrderQuantity)
                {
                    Random rnd = new Random();
                    keys.Add(rnd.Next(10000000, 99999999).ToString());
                    i++;
                }

                string keyList = "";
                foreach (string item in keys)
                {
                    keyList = item + ", " + keyList;
                }
                var body = $@"<p>Thank you, we have received your order!</p>                
                Your Product keys are {keyList}<br/>
                We will contact you if we have questions about your order.  Thanks!<br/>";
                using (var smtp = new SmtpClient())
                {
                    smtp.DeliveryMethod          = SmtpDeliveryMethod.SpecifiedPickupDirectory;
                    smtp.PickupDirectoryLocation = @"d:\mailpickup";
                    var message = new MailMessage();
                    message.To.Add(OrderEmail);
                    message.Subject    = "Buying Software - New Order";
                    message.Body       = body;
                    message.IsBodyHtml = true;
                    message.From       = new MailAddress("*****@*****.**");
                    await smtp.SendMailAsync(message);
                }

                var auditrecord = new AuditRecord();
                auditrecord.AuditActionType    = "Purchased a Software";
                auditrecord.DateTimeStamp      = DateTime.Now;
                auditrecord.KeySoftwareFieldID = 0;
                // Get current logged-in user
                var userID = User.Identity.Name.ToString();
                auditrecord.Username = userID;

                _context.AuditRecords.Add(auditrecord);



                await _context.SaveChangesAsync();

                return(RedirectToPage("OrderSuccess"));
            }
            return(Page());
        }
Beispiel #8
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.AuditRecords.Add(AuditRecord);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AuditRecord = await _context.AuditRecords.FindAsync(id);

            if (AuditRecord != null)
            {
                _context.AuditRecords.Remove(AuditRecord);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }