Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BrandExists(Brand.BrandID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 2
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            DateTime date = DateTime.Now;

            Repair.Date_Start = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);



            Report.Date = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);


            Repair1 = await _context.Repair.ToListAsync();

            StringBuilder a = new StringBuilder("RPR");

            a.Append(Repair1.Count().ToString());
            string b = a.ToString();


            Repair.RepairName = b;

            _context.Repair.Add(Repair);

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



            await _context.SaveChangesAsync();

            return(RedirectToPage("./../Repairs/Index"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            _context.Attach(Repair).State = EntityState.Modified;


            await _context.SaveChangesAsync();


            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 4
0
        // To protect from overposting attacks, please 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.Department.Add(Department);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync()
        {
            DateTime date = DateTime.Now;

            Repair.Date_Start = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);

            Report.Date = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);

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

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

            await _context.SaveChangesAsync();

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

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

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

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

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

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

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

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

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

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

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

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

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

            Model = await _context.Models.FindAsync(id);

            if (Model != null)
            {
                _context.Models.Remove(Model);
                await _context.SaveChangesAsync();
            }

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

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

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

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 12
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            Assets = await _context.Asset
                     .ToListAsync();


            if (!ModelState.IsValid)
            {
                return(Page());
            }
            StringBuilder a = new StringBuilder("ASS");

            a.Append(Assets.Count().ToString());
            string b = a.ToString();

            Asset.AssetName = b;

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

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 13
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(int id)
        {
            Employee1 = await _context.Employee.FindAsync(id);

            string sb = Employee1.Email;

            var myMail = new MailMessage();

            myMail.From = new MailAddress("Admin System<*****@*****.**>");

            myMail.Subject = "My Subject";
            myMail.To.Add(new MailAddress(sb.ToString()));
            myMail.IsBodyHtml   = true;
            myMail.BodyEncoding = System.Text.Encoding.UTF8;
            myMail.Body         = "My Body & <b>Description</b>";


            var credential = new NetworkCredential("*****@*****.**", "thanakrit2540bb!"); // User & Password
            var smtpClient = new SmtpClient();

            smtpClient.Port = 587;
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials           = credential;
            smtpClient.Host      = "smtp.gmail.com"; // SMTP
            smtpClient.EnableSsl = true;

            Report1 = await _context.Report
                      .ToListAsync();

            try
            {
                smtpClient.Send(myMail);

                smtpClient.Dispose();
                myMail.Dispose();
            }
            catch (Exception)
            {
                error = "Please check email security.";
            }


            DateTime date = DateTime.Now;

            Report.Date = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);



            StringBuilder a = new StringBuilder("RPT");

            a.Append(Report1.Count().ToString());
            string b = a.ToString();


            Report.ReportName = b;

            _context.Report.Add(Report);


            await _context.SaveChangesAsync();



            return(RedirectToPage("./../Includes/ShowJob"));
        }