Exemple #1
0
        public bool DeleteDepartment(DepartmentEntity entityObject)
        {
            string sqlStatement = "UPDATE Department SET Deleted=1 WHERE DepartmentId=@DepartmentId  " + Environment.NewLine;

            //execute
            Connection.Execute(sqlStatement, new { DepartmentId = entityObject.DepartmentId }, Transaction);
            return true;
        }
Exemple #2
0
 public bool DeleteDepartment(DepartmentEntity entityObject)
 {
     //execute
     using (var db = VinaGerman.Database.VinagermanDatabase.GetDatabaseInstance())
     {
         try
         {
             db.OpenConnection();
             return db.Resolve<IDepartmentDB>().DeleteDepartment(entityObject);
         }
         finally
         {
             db.CloseConnection();
         }
     }
 }
Exemple #3
0
        public DepartmentEntity AddOrUpdateDepartment(DepartmentEntity entityObject)
        {
            string sqlStatement = "";
            //if insert
            if (entityObject.DepartmentId > 0)
            {
                sqlStatement += "UPDATE Department SET  " + Environment.NewLine +
                "Phone=@Phone," + Environment.NewLine +
                "Description=@Description," + Environment.NewLine +
                "CompanyId=@CompanyId," + Environment.NewLine +
                "Deleted=@Deleted" + Environment.NewLine +
                "WHERE DepartmentId=@DepartmentId " + Environment.NewLine +
                "SELECT @DepartmentId AS DepartmentId " + Environment.NewLine;
            }
            else
            {
                sqlStatement += "INSERT INTO Department(  " + Environment.NewLine +
                "Phone," + Environment.NewLine +
                "Description," + Environment.NewLine +
                "CompanyId," + Environment.NewLine +
                "Deleted)" + Environment.NewLine +
                "VALUES (" + Environment.NewLine +
                "@Phone," + Environment.NewLine +
                "@Description," + Environment.NewLine +
                "@CompanyId," + Environment.NewLine +
                "@Deleted)" + Environment.NewLine +
                "SELECT SCOPE_IDENTITY() AS DepartmentId" + Environment.NewLine;
            }

            //execute
            entityObject.DepartmentId = Connection.ExecuteScalar<int>(sqlStatement, new
            {
                DepartmentId = entityObject.DepartmentId,
                Phone = entityObject.Phone,
                Description = entityObject.Description,
                CompanyId = entityObject.CompanyId,
                Deleted = (entityObject.Deleted ? 1 : 0)
            }, Transaction);
            return entityObject;
        }