Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Mvc.Rendering;
- using Microsoft.EntityFrameworkCore;
- using WebApplication2.Data;
- using WebApplication2.Models;
- namespace WebApplication2.Controllers
- {
- public class BOesController : Controller
- {
- private readonly ApplicationDbContext _context;
- public BOesController(ApplicationDbContext context)
- {
- _context = context;
- }
- public async Task<IActionResult> Teste()
- {
- var bo = _context.BOs.LastOrDefault();
- return Content(bo.BOGCM);
- }
- public IActionResult Criar() {
- var bo = _context.BOs.Where(w => w.BoAno == DateTime.Today.Year).Max(m => m.BoSequencial) + 1;
- var newBO = new BO
- {
- BOGCM = $"{bo}-{DateTime.Today.Year}"
- };
- _context.Add(newBO);
- _context.SaveChanges();
- return Content(newBO.BOGCM);
- }
- public IActionResult Criar2()
- {
- var bo = _context.BOs.LastOrDefault();
- var NewNumero = bo.BoSequencial + 1;
- var newBO = new BO
- {
- BOGCM = $"{NewNumero}-{DateTime.Today.Year}"
- };
- _context.Add(newBO);
- _context.SaveChanges();
- return Content(newBO.BOGCM);
- }
- private bool BOExists(int id)
- {
- return _context.BOs.Any(e => e.BOId == id);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement