Example #1
0
        public async Task <IActionResult> Crear(int?IdPer)
        {
            if (IdPer == null)
            {
                return(NotFound());
            }
            IT41 it0p     = new IT41();
            var  personal = await _context.Personals
                            .SingleOrDefaultAsync(m => m.Id == IdPer);

            ViewBag.GpoCiaG      = personal.Gbukrs;
            ViewBag.Nombre       = personal.Cname;
            ViewBag.Bukrs        = personal.Bukrs;
            ViewBag.NoPer        = personal.Pernr;
            ViewBag.ListofPerPru = _bukrs.GetPeriodoPrueba();
            var items = new List <SelectListItem>();

            items = _bukrs.DaClasedeMedida(personal.Gbukrs, personal.Bukrs);
            ViewBag.ListaClases = items.ToList();
            var esta1 = new List <Estatus_stat2>();

            esta1               = _bukrs.GetEstatus1(personal.Bukrs, personal.Gbukrs);
            ViewBag.ListaEst    = esta1.ToList();
            ViewBag.ClaseFechas = _bukrs.GetClasedeFecha();
            it0p.Dat01          = DateTime.Now;
            var lastIt0 = await _context.IT1s.LastOrDefaultAsync(m => m.PersonalId == IdPer);

            if (lastIt0 == null)
            {
                it0p.BegDa = DateTime.Now;
            }
            else
            {
                it0p.BegDa = lastIt0.BegDa.AddDays(1);
            }
            it0p.Gbukrs = personal.Gbukrs;
            it0p.Bukrs  = personal.Bukrs;
            string   dateInput  = "Jan 1, 9999";
            DateTime parsedDate = DateTime.Parse(dateInput);

            it0p.EndDa = parsedDate;
            var userNa = User.FindFirstValue(ClaimTypes.Name);

            it0p.Uname      = userNa;
            it0p.Pernr      = personal.Pernr;
            it0p.Aedtm      = DateTime.Now;
            it0p.PersonalId = personal.Id;

            return(View(it0p));
        }