Пример #1
0
        private List <RejectReason> fillRejectReasonList()
        {
            RejectReasonBusiness _RejectReasonBusiness = new RejectReasonBusiness();
            RejectReasonList     _RejectReasonList     = _RejectReasonBusiness.SelectRows(null, null, null);

            return(_RejectReasonList);
        }
        public int SaveRows(DbTransaction pTran, RejectReasonList RejectReasonList, bool CreateTransaction)
        {
            int           intRows   = 0;
            DbTransaction objTran   = pTran;
            Exception     exception = null;

            try
            {
                if (pTran == null && CreateTransaction == true)
                {
                    objTran = RejectReasonData.CreateTransaction();
                }
                intRows = RejectReasonData.SaveRows(objTran, RejectReasonList);
                if (pTran == null && objTran != null && CreateTransaction == true)
                {
                    RejectReasonData.CommitTransaction(objTran, true);
                    objTran = null;
                }
            }
            catch (Exception EX)
            {
                exception = EX;
                if (pTran == null && objTran != null && CreateTransaction == true)
                {
                    RejectReasonData.RollbackTransaction(objTran, true);
                    objTran = null;
                }
            }
            finally
            {
            }
            return(intRows);
        }
Пример #3
0
        public ICollection <RejectReasonDTO> GetAllRejectReasonFromDB()
        {
            ICollection <RejectReasonDTO> outputList = default(ICollection <RejectReasonDTO>);

            try
            {
                // 1- Select All Rejection Reasons From DB
                RejectReasonBusiness _RejectReasonBusiness = new RejectReasonBusiness();
                RejectReasonList     _RejectReasonList     = _RejectReasonBusiness.SelectRows(null, null, null);

                if (_RejectReasonList != null && _RejectReasonList.Count > 0)

                {
                    // 2- Prepare Mapping Objects (Fill Values from DB)
                    Mapper._RejectReasonList = fillRejectReasonList(); //default(List<Rejection Reason>);


                    // 3- Perform Mapping to Output
                    outputList = Mapper.MapRejectReasonAsOutput();
                }
            }
            catch (Exception ex)
            {
                // Log Exception Here
                throw; //new Exception(ex.Message);
            }

            return(outputList);
        }
Пример #4
0
        public RejectReasonDTO UpdateRejectReasonInDB(RejectReasonDTO rejectReasonDTO)
        {
            BaseDataAccess _db = new BaseDataAccess();

            using (DbTransaction dbTransaction = _db.CreateTransaction())
            {
                try

                {
                    // 1- Perform Mapping to  Input (for Saving in DB)
                    if (Mapper.MapRejectReasonAsInput(rejectReasonDTO))
                    {
                        // 2- Select RejectReason to be updated
                        RejectReasonBusiness rejectReasonBusiness = new RejectReasonBusiness();
                        RejectReasonList     rejectReasonList     = rejectReasonBusiness.SelectRows(Mapper._WorkField.Id, null, null);

                        if (rejectReasonList != null && rejectReasonList.Count > 0)
                        {
                            rejectReasonList[0].Id     = Mapper._RejectReason.Id;
                            rejectReasonList[0].name   = Mapper._RejectReason.name;
                            rejectReasonList[0].nameAr = Mapper._RejectReason.nameAr;


                            // 3- Update RejectReason Data by Input Values
                            rejectReasonBusiness = new RejectReasonBusiness();
                            if (rejectReasonBusiness.UpdateRow(dbTransaction, rejectReasonList[0]) > 0)
                            {
                                dbTransaction.Commit();
                            }

                            else
                            {
                                dbTransaction.Rollback();
                                throw new Exception("DataBase Operation Failure");
                            }
                        }
                        else
                        {
                            dbTransaction.Rollback();
                            throw new Exception("RejectReason Id Not Found in DB");
                        }
                    }
                    else
                    {
                        throw new ArgumentNullException("rejectReasonDTO");
                    }
                }
                catch (Exception ex)
                {
                    dbTransaction.Rollback();
                    throw;
                }
            }

            return(rejectReasonDTO);
        }
        public RejectReasonList SelectRows(DbTransaction pTran, System.Int32?Id, System.String name, System.String nameAr)
        {
            RejectReasonList RejectReasonList = new RejectReasonList();
            Exception        exception        = null;

            DbParameter[] Parameters = new DbParameter[3];
            Parameters[0] = _getIdParameter(Id, ParameterDirection.Input);
            Parameters[1] = _getnameParameter(name, ParameterDirection.Input);
            Parameters[2] = _getnameArParameter(nameAr, ParameterDirection.Input);

            DbDataReader Dr = ExecuteReader(pTran, "[Lookups].[SelectRejectReason]", Parameters);

            try
            {
                if (Dr != null)
                {
                    while (Dr.Read())
                    {
                        RejectReason RejectReason = new RejectReason();
                        if (Dr["Id"] != DBNull.Value)
                        {
                            RejectReason.Id = (System.Int32)Dr["Id"];
                        }
                        if (Dr["name"] != DBNull.Value)
                        {
                            RejectReason.name = (System.String)Dr["name"];
                        }
                        if (Dr["nameAr"] != DBNull.Value)
                        {
                            RejectReason.nameAr = (System.String)Dr["nameAr"];
                        }
                        RejectReasonList.FillRow(RejectReason);
                        RejectReason = null;
                    }
                }
            }
            catch (Exception Ex)
            {
                exception = Ex;
            }
            finally
            {
                if (Dr != null)
                {
                    if (Dr.IsClosed == false)
                    {
                        Dr.Close();
                    }
                    Dr = null;
                }
            }
            return(RejectReasonList);
        }
Пример #6
0
        public bool DeleteRejectReasonFromDB(int id)
        {
            bool result = default(bool);

            BaseDataAccess _db = new BaseDataAccess();

            using (DbTransaction dbTransaction = _db.CreateTransaction())
            {
                try
                {
                    // 1- Select RejectReason From DB by ID
                    RejectReasonBusiness rejectReasonBusiness = new RejectReasonBusiness();
                    RejectReasonList     rejectReasonList     = rejectReasonBusiness.SelectRows(id, null, null);

                    if (rejectReasonList != null && rejectReasonList.Count > 0)
                    {
                        foreach (RejectReason rejectReason in rejectReasonList)
                        {
                            rejectReasonBusiness = new RejectReasonBusiness();
                            rejectReasonBusiness.DeleteRow(dbTransaction, rejectReason);
                        }

                        dbTransaction.Commit();
                        result = true;
                    }

                    else
                    {
                        dbTransaction.Rollback();
                        throw new Exception("RejectReason Id Not Found in DB");
                    }
                }
                catch (Exception)
                {
                    dbTransaction.Rollback();
                    throw new Exception("DataBase Operation Failure");
                }
            }

            return(result);
        }
        public int SaveRows(DbTransaction pTran, RejectReasonList RejectReasonList)
        {
            int intRows = 0;

            for (int i = 0; i < RejectReasonList.Count; i++)
            {
                switch (RejectReasonList[i].CommonState)
                {
                case CommonState.Added:
                    intRows += InsertRow(pTran, RejectReasonList[i]);
                    break;

                case CommonState.Modified:
                    intRows += UpdateRow(pTran, RejectReasonList[i]);
                    break;

                case CommonState.Deleted:
                    intRows += DeleteRow(pTran, RejectReasonList[i]);
                    break;
                }
            }

            return(intRows);
        }
Пример #8
0
        public RejectReasonDTO GetRejectReasonByIDFromDB(int id)
        {
            {
                ICollection <RejectReasonDTO> outputList = default(ICollection <RejectReasonDTO>);
                RejectReasonDTO output = new RejectReasonDTO();

                try
                {
                    RejectReasonBusiness _RejectReasonBusiness = new RejectReasonBusiness();
                    RejectReasonList     _RejectReasonList     = _RejectReasonBusiness.SelectRows(id, null, null);

                    if (_RejectReasonList != null && _RejectReasonList.Count > 0)
                    //outputList = Mapper.MapUserAsOutput();
                    {
                        // 2- Prepare Mapping Objects (Fill Values from DB)
                        Mapper._RejectReasonList = _RejectReasonList;


                        // 3- Perform Mapping to Output
                        outputList = Mapper.MapRejectReasonAsOutput();

                        if (outputList != null && outputList.Count > 0)
                        {
                            output = outputList.FirstOrDefault();
                        }
                    }
                }
                catch (Exception ex)
                {
                    // Log Exception Here
                    throw; //new Exception(ex.Message);
                }

                return(output);
            }
        }
        public int SaveRows(RejectReasonList RejectReasonList)
        {
            DbTransaction Tran = null;

            return(SaveRows(Tran, RejectReasonList));
        }
 public int SaveRows(DbTransaction pTran, RejectReasonList RejectReasonList)
 {
     return(SaveRows(pTran, RejectReasonList, true));
 }