public void Update(mp_family_intake intake)
        {
            var old = _context.mp_family_intake.FirstOrDefault(e => e.id == intake.id);

            intake.updated_at = DateTime.Now;

            intake.created_at = old.created_at;
            intake.created_by = old.created_by;

            _context.Entry(old).CurrentValues.SetValues(intake);
            _context.SaveChanges();
        }
Ejemplo n.º 2
0
        public IActionResult GetFamilyIntake(Guid appointment_id)
        {
            var intake = _familyIntakeService.Get().FirstOrDefault(e => e.appointment_id == appointment_id);

            if (intake == null)
            {
                intake = new mp_family_intake
                {
                    appointment_id = appointment_id
                };
            }

            return(Ok(intake));
        }
 public IActionResult Partial(Guid appointment_id, int?id)
 {
     if (id.HasValue)
     {
         var intake = _familyIntakeService.Get(id.Value);
         return(PartialView(intake));
     }
     else
     {
         var intake = new mp_family_intake
         {
             appointment_id = appointment_id
         };
         return(PartialView(intake));
     }
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> PostFamilyIntake(mp_family_intake intake)
        {
            var old = _familyIntakeService.Get().FirstOrDefault(e => e.appointment_id == intake.appointment_id);

            var email = _userManager.GetUserId(HttpContext.User);
            var user  = await _userManager.FindByEmailAsync(email);

            if (old == null)
            {
                //this is a new form
                intake.created_by = user.Id;
                _familyIntakeService.Add(intake);
            }
            else
            {
                //update the existing form
                intake.created_by = old.created_by;
                intake.id         = old.id;
                _familyIntakeService.Update(intake);
            }

            return(Ok(200));
        }
 public void Add(mp_family_intake intake)
 {
     intake.created_at = DateTime.Now;
     _context.mp_family_intake.Add(intake);
     _context.SaveChanges();
 }