コード例 #1
0
        public IActionResult NewRegistration()
        {
            Contacts contact = Regs.Contact;

            contact.DateOfBirth = DateTime.Now.AddYears(0 - Convert.ToInt32(contact.Age));
            contact.Save(HttpContext);

            CommunityUnit unit = new CommunityUnit();

            string[] tokens = Regs.Unit.Split(' ');
            if (!string.IsNullOrEmpty(Regs.Unit) && tokens.Length > 1)
            {
                int.TryParse(tokens[0], out int idnt);
                unit.Id = idnt;
            }

            Referee referee = new Referee();

            tokens = Regs.Referee.Split(' ');
            if (!string.IsNullOrEmpty(Regs.Referee) && tokens.Length > 1)
            {
                int.TryParse(tokens[0], out int idnt);
                referee.Id = idnt;
            }

            Facility facility = new Facility();

            tokens = Regs.Facility.Split(' ');
            if (!string.IsNullOrEmpty(Regs.Facility) && tokens.Length > 1)
            {
                int.TryParse(tokens[0], out int idnt);
                facility.Id = idnt;
            }

            Record record = Regs.Record;

            record.Contact = contact;
            record.Referee = referee;
            record.Unit    = unit;
            record.Save(HttpContext);

            Screening screen = Regs.Screen;

            screen.Record = record;
            screen.Save(HttpContext);

            Appointment appointment = Regs.Appointment;

            appointment.Contact  = contact;
            appointment.Facility = facility;
            appointment.Source   = new AppointmentSource {
                Id = 1
            };
            appointment.Service = new AppointmentService {
                Id = 1
            };
            appointment.Save(HttpContext);

            return(LocalRedirect("/contacts/"));
        }