예제 #1
0
        public static CheckResult ValidateSave(DSModel db, DriverMedicalModel model)
        {
            CheckResult res = new CheckResult(model);

            if (model.DriverID == 0)
            {
                res.AddError("Driver cannot be empty!", model.GetName(p => p.DriverID));
            }
            if (model.MedTypeID == 0)
            {
                res.AddError("Medical type cannot be empty!", model.GetName(p => p.MedTypeID));
            }
            if (model.ExaminationDate == DateTime.MinValue)
            {
                res.AddError("Examination date cannot be empty!", model.GetName(p => p.ExaminationDate));
            }
            if (model.ValidityDate == DateTime.MinValue)
            {
                res.AddError("Validity date cannot be empty!", model.GetName(p => p.ValidityDate));
            }
            if (model.ValidityDate.Date <= model.ExaminationDate.Date)
            {
                res.AddError("Validity date cannot be earlier than Examination date!", model.GetName(p => p.ValidityDate));
            }

            return(res);
        }
예제 #2
0
        private static void InsertMedical(DSModel db, KeyBinder key, DriverMedicalModel model)
        {
            DriversMedical poco = new DriversMedical();

            model.Map(poco);
            db.Add(poco);

            key.AddKey(poco, model, model.GetName(p => p.DriverMedicalID));
            db.FlushChanges();
            SaveReminders(db, key, model, poco);
        }