Esempio n. 1
0
        internal static int AddDrive(TrinityContext context, AddDriveViewModel drive)
        {
            Drives newDrive = new Drives()
            {
                StartingPoint = drive.StartingPoint, Destination = drive.Destination, Date = drive.Date, Driver = true, Passengers = drive.Passengers
            };

            context.Drives.Add(newDrive);
            context.SaveChanges();

            int did = newDrive.ID;

            return(did);
        }
Esempio n. 2
0
        internal static bool SSNInDB(TrinityContext context, AddDriveViewModel drive)
        {
            var driveSSN = context.Persons
                           .Where(p => p.SSN == drive.SSN)
                           .FirstOrDefault();

            if (driveSSN != null)
            {
                int did    = AddDrive(context, drive);
                var person = context.Persons.Where(p => p.SSN == drive.SSN).FirstOrDefault();

                context.PTD.Add(new PTD()
                {
                    PID = person.ID, DID = did
                });
                context.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }