Example #1
0
        public async Task <IActionResult> AddDeliveryActa(DeliveryActaViewModel model)
        {
            if (ModelState.IsValid)
            {
                //UPDATE field sequence in table ActasSequences

                ActaSequence nextSequence = _context.ActaSequences.Single();

                var modelfull = new DeliveryActaViewModel
                {
                    StudentID      = model.StudentID,
                    Usucrea        = User.Identity.Name,
                    Entrega3       = model.Entrega3,
                    Entrega4       = model.Entrega4,
                    Entrega5       = model.Entrega5,
                    Entrega6       = model.Entrega6,
                    Prefix         = nextSequence.Prefix,
                    PrefixSequence = nextSequence.Sequence
                };
                var examen = await _converterHelper.ToCreditAsync(modelfull, true);

                _context.DeliveryActas.Add(examen);

                // Incremento la secuencia
                nextSequence.Sequence += 1;

                await _context.SaveChangesAsync();

                return(RedirectToAction($"Details/{model.StudentID}"));
            }

            return(View(model));
        }
Example #2
0
 public async Task <DeliveryActa> ToDeliveryActaAsync(DeliveryActaViewModel model, bool isNew)
 {
     return(new DeliveryActa
     {
         Id = isNew ? 0 : model.Id,
         Entrega3 = model.Entrega3,
         Entrega4 = model.Entrega4,
         Entrega5 = model.Entrega5,
         Entrega6 = model.Entrega6,
         Entrega7 = model.Entrega7,
         Usucrea = model.Usucrea,
         Estudents = await _dataContext.Estudents.FindAsync(model.StudentID)
     });
 }
Example #3
0
 public async Task <DeliveryActa> ToCreditAsync(DeliveryActaViewModel model, bool isNew)
 {
     //int mes = int.Parse(model.DeadlinePay.ToString());
     return(new DeliveryActa
     {
         Id = isNew ? 0 : model.Id,
         FechaCrea = DateTime.Now,
         Usucrea = model.Usucrea,
         Estudents = await _dataContext.Estudents.FindAsync(model.StudentID),
         Entrega3 = model.Entrega3,
         Entrega4 = model.Entrega4,
         Entrega5 = model.Entrega5,
         Entrega6 = model.Entrega6,
         Entrega7 = model.Entrega7,
         Prefix = model.Prefix,
         PrefixSequence = model.PrefixSequence
     });
 }
Example #4
0
        public async Task <IActionResult> EditDelivery(DeliveryActaViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var deliveyActa = await _converterHelper.ToDeliveryActaAsync(model, false);

                    _context.DeliveryActas.Update(deliveyActa);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction($"{nameof(Details)}/{model.StudentID}"));
                }
                catch (Exception e)
                {
                    throw;
                }
            }
            return(View(model));
        }
Example #5
0
        public async Task <IActionResult> AddDeliveryActa(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var employe = await _context.Estudents.FindAsync(id);

            if (employe == null)
            {
                return(NotFound());
            }
            var model = new DeliveryActaViewModel
            {
                StudentID = employe.Id,


                Usucrea = User.Identity.Name
            };

            return(View(model));
        }