Esempio n. 1
0
        public ApprovalModel UpdateApproval(ApprovalModel approvalModel)
        {
            _approvals.ReplaceOne(approval => approval.approvalNumber.Equals(approvalModel.approvalNumber), approvalModel);
            ApprovalModel tmpApprovalModel = GetOneApprovalByPersonId(approvalModel.approvalPersonId);

            return(tmpApprovalModel);
        }
Esempio n. 2
0
        public List <ThreeObjectsModel> GetAllThreeObjects()
        {
            List <ThreeObjectsModel> threeObjectsList = new List <ThreeObjectsModel>();

            List <PersonModel> allPersonsId = personRepository.GetAllPersonsId();

            for (int i = 0; i < allPersonsId.Count; i++)
            {
                ThreeObjectsModel threeObjects = new ThreeObjectsModel();

                PersonModel personModel;

                if (studentRepository.GetOneStudentById(allPersonsId[i].personId) != null)
                {
                    personModel = studentRepository.GetOneStudentById(allPersonsId[i].personId);
                }
                else
                {
                    personModel = teacherRepository.GetOneTeacherById(allPersonsId[i].personId);
                }

                VehicleModel  vehicleModel  = vehicleRepository.GetOneVehicleByOwnerId(allPersonsId[i].personId);
                ApprovalModel approvalModel = approvalRepository.GetOneApprovalByPersonId(allPersonsId[i].personId);

                threeObjects.personModel   = personModel;
                threeObjects.vehicleModel  = vehicleModel;
                threeObjects.approvalModel = approvalModel;

                threeObjectsList.Add(threeObjects);
            }

            return(threeObjectsList);
        }
Esempio n. 3
0
        public ThreeObjectsModel GetAllThreeObjectsByVehicleNumber(string vehicleNumber)
        {
            ThreeObjectsModel threeObjects = new ThreeObjectsModel();


            VehicleModel vehicleModel = vehicleRepository.GetOneVehicleByNumber(vehicleNumber);
            PersonModel  personModel;

            if (studentRepository.GetOneStudentById(vehicleModel.vehicleOwnerId) != null)
            {
                personModel = studentRepository.GetOneStudentById(vehicleModel.vehicleOwnerId);
            }
            else
            {
                personModel = teacherRepository.GetOneTeacherById(vehicleModel.vehicleOwnerId);
            }

            ApprovalModel approvalModel = approvalRepository.GetOneApprovalByPersonId(vehicleModel.vehicleOwnerId);

            threeObjects.personModel   = personModel;
            threeObjects.vehicleModel  = vehicleModel;
            threeObjects.approvalModel = approvalModel;

            return(threeObjects);
        }
Esempio n. 4
0
        public ApprovalModel AddApproval(ApprovalModel approvalModel)
        {
            if (_approvals.Find <ApprovalModel>(Builders <ApprovalModel> .Filter.Eq(approval => approval.approvalPersonId, approvalModel.approvalPersonId)).FirstOrDefault() == null)
            {
                _approvals.InsertOne(approvalModel);
            }

            ApprovalModel tmpApprovalModel = GetOneApprovalByPersonId(approvalModel.approvalPersonId);

            return(tmpApprovalModel);
        }
        public ApprovalModel UpdateApproval(ApprovalModel approval)
        {
            int i = -1;

            using (OleDbCommand command = new OleDbCommand())
            {
                i = base.ExecuteNonQuery(ApprovalStringsInner.UpdateApproval(approval));
            }

            return(GetOneApprovalByCode(approval.approvalCode));
        }
 static public SqlCommand UpdateApproval(ApprovalModel approvalModel)
 {
     if (GlobalVariable.queryType == 0)
     {
         return(CreateSqlCommand(approvalModel, queryApprovalsUpdate));
     }
     else
     {
         return(CreateSqlCommand(approvalModel, procedureApprovalsUpdate));
     }
 }
        public static ApprovalModel ToObject(DataRow reader)
        {
            ApprovalModel approvalModel = new ApprovalModel();

            approvalModel.approvalCode     = reader[0].ToString();
            approvalModel.approvalFrom     = DateTime.Parse(reader[1].ToString());
            approvalModel.approvalUntil    = DateTime.Parse(reader[2].ToString());
            approvalModel.approvalPersonId = reader[3].ToString();
            approvalModel.approvalNumber   = int.Parse(reader[4].ToString());

            Debug.WriteLine("ApprovalModel:" + approvalModel.ToString());
            return(approvalModel);
        }
Esempio n. 8
0
        static private OleDbCommand CreateOleDbCommand(ApprovalModel approval, string commandText)
        {
            OleDbCommand command = new OleDbCommand(commandText);

            command.Parameters.AddWithValue("@approvalCode", approval.approvalCode);
            command.Parameters.AddWithValue("@approvalFrom", approval.approvalFrom);
            command.Parameters.AddWithValue("@approvalUntil", approval.approvalUntil);
            command.Parameters.AddWithValue("@approvalPersonId", approval.approvalPersonId);
            if (approval.approvalNumber > 0)
            {
                command.Parameters.AddWithValue("@approvalNumber", approval.approvalNumber);
            }
            return(command);
        }
        public ApprovalModel AddApproval(ApprovalModel approvalModel)
        {
            DataTable dt = new DataTable();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(ApprovalStringsSql.AddApproval(approvalModel));
            }
            foreach (DataRow ms in dt.Rows)
            {
                approvalModel = ApprovalModel.ToObject(ms);
            }

            return(approvalModel);
        }
        public ApprovalModel GetOneApprovalByNumber(int approvalNumber)
        {
            DataTable     dt  = new DataTable();
            ApprovalModel app = new ApprovalModel();

            using (OleDbCommand command = new OleDbCommand())
            {
                dt = GetMultipleQuery(ApprovalStringsInner.GetOneApprovalByNumber(approvalNumber));
            }

            foreach (DataRow ms in dt.Rows)
            {
                app = ApprovalModel.ToObject(ms);
            }
            return(app);
        }
        public List <ApprovalModel> GetAllApprovals()
        {
            DataTable            dt  = new DataTable();
            List <ApprovalModel> apv = new List <ApprovalModel>();


            using (OleDbCommand command = new OleDbCommand())
            {
                dt = GetMultipleQuery(ApprovalStringsInner.GetAllApprovals());
            }

            foreach (DataRow ms in dt.Rows)
            {
                apv.Add(ApprovalModel.ToObject(ms));
            }
            return(apv);
        }
        public List <ApprovalModel> GetAllApprovals()
        {
            DataTable dt = new DataTable();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(ApprovalStringsSql.GetAllApprovals());
            }

            List <ApprovalModel> arrApproval = new List <ApprovalModel>();

            foreach (DataRow ms in dt.Rows)
            {
                arrApproval.Add(ApprovalModel.ToObject(ms));
            }

            return(arrApproval);
        }
        public ThreeObjectsModel UpdateThreeObjects(ThreeObjectsModel threeObjectsModel)
        {
            if (threeObjectsModel.personModel is StudentModel)
            {
                studentRepository.UpdateStudent(threeObjectsModel.personModel as StudentModel);
            }

            if (threeObjectsModel.personModel is TeacherModel)
            {
                teacherRepository.UpdateTeacher(threeObjectsModel.personModel as TeacherModel);
            }

            VehicleModel  vehicle  = vehicleRepository.UpdateVehicle(threeObjectsModel.vehicleModel);
            ApprovalModel approval = approvalRepository.UpdateApproval(threeObjectsModel.approvalModel);

            ThreeObjectsModel threeObjectsModel2 = GetAllThreeObjectsByPersonId(threeObjectsModel.personModel.personId);

            return(threeObjectsModel2);
        }
        public ApprovalModel GetOneApprovalByNumber(int approvalNumber)
        {
            DataTable dt = new DataTable();

            if (approvalNumber < 1)
            {
                throw new ArgumentOutOfRangeException();
            }
            ApprovalModel approvalModel = new ApprovalModel();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(ApprovalStringsSql.GetOneApprovalByNumber(approvalNumber));
            }

            foreach (DataRow ms in dt.Rows)
            {
                approvalModel = ApprovalModel.ToObject(ms);
            }

            return(approvalModel);
        }
        public ApprovalModel GetOneApprovalByPersonId(string personId)
        {
            DataTable dt = new DataTable();

            if (personId.Equals(string.Empty) || personId.Equals(""))
            {
                throw new ArgumentOutOfRangeException();
            }
            ApprovalModel approvalModel = new ApprovalModel();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(ApprovalStringsSql.GetOneApprovalByPersonId(personId));
            }

            foreach (DataRow ms in dt.Rows)
            {
                approvalModel = ApprovalModel.ToObject(ms);
            }

            return(approvalModel);
        }
Esempio n. 16
0
 static public OleDbCommand UpdateApproval(ApprovalModel approvalModel)
 {
     return(CreateOleDbCommand(approvalModel, queryApprovalsUpdate));
 }
Esempio n. 17
0
 static public OleDbCommand AddApproval(ApprovalModel approvalModel)
 {
     return(CreateOleDbCommand(approvalModel, queryApprovalsPost));
 }
 public ThreeObjectsModel(PersonModel person2, VehicleModel vehicle2, ApprovalModel approval2)
 {
     personModel   = person2;
     vehicleModel  = vehicle2;
     approvalModel = approval2;
 }